hpi-swt2/workshop-portal

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

Summary

Maintainability
Test Coverage
<div class="container-fluid" id="applicants_overview">
  <h3><%= t '.title', title: @event.name %></h3>
  <div id="free_places"><%= t '.free_places', count: @free_places %></div>
  <div id="occupied_places"><%= t '.occupied_places', count: @occupied_places %></div>

  <table id="applicants" class="table table-striped">
    <thead>
    <tr>
      <th>
        <%= sort_caret(Profile.human_attribute_name(:name), :name) %>
      </th>
      <th>
        <%= sort_caret(Profile.human_attribute_name(:gender), :gender) %>
      </th>
      <th>
        <%= sort_caret(Profile.human_attribute_name(:age), :age) %>
      </th>
      <th>
        <%= t '.participations' %> <br>
        <%= t '.accepted_rejected' %>
      </th>
      <th>
        <button
         class="btn btn-default btn-sm pull-right has-popover"
         title="<%= t '.filter_by' %>"
         data-toggle="popover"
         data-placement="bottom"
         data-content="<%= (render :partial => 'application_letters/application_filter_popover').gsub('\n', '') %>"
         data-html="true"><%= t '.filter_by' %></button>
        <%= t '.status' %>
      </th>
      <th></th>
    </tr>
    </thead>
    <tbody>
    <%
      @application_letters.sort_by! {|l| l.user.profile.send(params[:sort]) } if params[:sort]
      @application_letters.reverse! if params[:order] == 'descending'
      @application_letters.select {|l| l.user.profile }.each do | application_letter | %>
        <tr>
          <td><%= application_letter.user.profile.name %></td>
          <td><%= application_letter.user.profile.gender %></td>
          <td><%= application_letter.user.profile.age  %></td>
          <td><%= application_letter.user.accepted_applications_count(@event) %> / <%= application_letter.user.rejected_applications_count(@event) %></td>
          <td>
            <%= render :partial => 'application_letters/application_selective', locals: {application_letter: application_letter} %>
          </td>
          <td>
            <%= link_to t('.details'), application_letter_path(application_letter), :class => 'btn btn-default' %>
          </td>
        </tr>
    <% end %>
    </tbody>
  </table>

  <div class="container-fluid no-padding">
    <div class="btn-group" role="group">
      <%= link_to "Alle annehmen",
          events_path, :class => 'btn btn-default'%>

      <%= link_to "Alle drucken",
          events_path, :class => 'btn btn-default'%>
    </div>

    <% if not @event.applications_classified? %>
      <div class="btn-group pull-right tooltip-wrapper has-tooltip" role="group" data-toggle="tooltip" title="<%= t '.unclassified_applications_left'%>">
        <%= link_to t('events.badges.print_button_label'), event_badges_path(@event), :class => 'btn btn-default'%>
        <%= button_tag t('.sending_acceptances'), type: 'button', class: 'send-emails-button btn btn-default', disabled: true %>
        <%= button_tag t('.sending_rejections'), type: 'button', class: 'send-emails-button btn btn-default', disabled: true %>
      </div>
    <% elsif (@event.compute_free_places < 0) %>
      <div class="btn-group pull-right tooltip-wrapper has-tooltip" role="group" data-toggle="tooltip" title="<%= t '.maximum_number_of_participants_exeeded'%>">
        <%= link_to t('events.badges.print_button_label'), event_badges_path(@event), :class => 'btn btn-default'%>
        <%= button_tag t('.sending_acceptances'), type: 'button', class: 'send-emails-button btn btn-default', disabled: true %>
        <%= button_tag t('.sending_rejections'), type: 'button', class: 'send-emails-button btn btn-default', disabled: true %>
      </div>
    <% else %>
      <div class="btn-group pull-right" role="group">
        <%= link_to t('events.badges.print_button_label'), event_badges_path(@event), :class => 'btn btn-default'%>
        <%= link_to t('.sending_acceptances'), event_send_acceptance_emails_path, class: 'send-emails-button btn btn-default' %>
        <%= link_to t('.sending_rejections'), event_send_rejection_emails_path, class: 'send-emails-button btn btn-default' %>
      </div>
    <% end %>
  </div>
</div>