vol1ura/Sat_9am_5km

View on GitHub
app/views/events/show.html.erb

Summary

Maintainability
Test Coverage
<% head_info :title, t('.title', event: @event.name) %>
<% head_info :description, strip_tags(@event.description).squish %>

<% unless @event.active %>
  <div class="alert alert-danger d-flex align-items-center" role="alert">
    <i class="fa-solid fa-triangle-exclamation"></i>&nbsp;
    <div>
      <strong><%= t '.attention' %></strong> <%= @total_activities.zero? ? t('.opening_soon') : t('.start_cancelled') %>
      <%= t '.inactivity_disclaimer_html', link: Rails.configuration.telegram[top_level_domain] %>
    </div>
  </div>
<% end %>

<div class="row mb-3 px-3">
  <div class="col-12 col-xxl-10 mx-auto position-relative px-0">
    <div class="position-absolute top-0 bg-dark bg-gradient bg-opacity-25 w-100 px-3 rounded-top">
      <h4 class="text-light"><%= @event.name %></h4>
    </div>
    <%= event_main_image_tag @event, class: 'img-fluid rounded', alt: t('.event_place'), title: @event.name %>
  </div>
</div>

<%= sanitized_text @event.description %>

<h4><%= t '.our_contacts' %></h4>
<div class="d-flex flex-wrap">
  <% @event.contacts.order(:contact_type).each do |contact| %>
    <%=
      external_link_to(
        contact.link.html_safe,
        class: 'mb-2',
        title: human_contact_type(contact.contact_type),
      ) do
    %>
      <%= render "events/contacts/#{contact.contact_type}" %>
    <% end %>
  <% end %>
</div>

<h2><%= t '.results' %></h2>
<div class="row">
  <div class="col-12">
    <% if @total_activities.zero? %>
      <p><%= t '.no_results_disclaimer' %></p>
    <% else %>
      <table class="table table-striped table-centered">
        <thead>
          <tr>
            <th>#</th>
            <th><%= t 'activities.index.date' %></th>
            <th><%= t 'activities.index.athletes' %></th>
            <th><%= t 'activities.index.volunteers' %></th>
            <th class="hidden-on-phone"><%= t 'activities.index.first_man' %></th>
            <th class="hidden-on-phone"><%= t 'activities.index.first_woman' %></th>
          </tr>
        </thead>
        <tbody class="table-group-divider">
          <%= render partial: 'activity', collection: @event.activities.published.order(date: :desc), cached: true %>
        </tbody>
      </table>
      <%= render partial: '/expand_button' if @total_activities > 15 %>
    <% end %>
  </div>
</div>

<div class="row mt-3">
  <div class="col-12 col-md-4">
    <h3><%= t '.how_participate' %></h3>
    <p><%= t '.about_participation_html', registration_link: 'https://t.me/sat9am5kmbot' %></p>
  </div>
  <div class="col-12 col-md-4">
    <h3><%= t '.how_find_us' %></h3>
    <p><%= @event.place %></p>
  </div>
  <div class="col-12 col-md-4">
    <h3><%= t '.volunteers' %></h3>
    <p><%= t '.about_volunteers_html', roster_link: volunteering_event_path(@event.code_name) %></p>
  </div>
</div>