osunyorg/admin

View on GitHub
app/views/server/universities/index.html.erb

Summary

Maintainability
Test Coverage
<% content_for :title, University.model_name.human(count: 2) %>

<div class="d-flex justify-content-between mb-4">
  <p>
    <%= @universities.total_count %>
    <%= University.model_name.human(count: @universities.total_count).downcase %>, 
    <%= t('server_admin.universities.contributing', count: University.contributing.count) %>
  </p>
  <%= render  'filters', current_path: server_universities_path %>
</div>

<div class="table-responsive">
  <table class="<%= table_classes %>">
    <thead>
      <tr>
        <th><%= University.human_attribute_name('name') %></th>
        <th><%= University.human_attribute_name('url') %></th>
        <th><%= University.human_attribute_name('public_or_private') %></th>
        <th><%= Language.model_name.human(count: 2) %></th>
        <th><%= User.model_name.human(count: 2) %></th>
        <th><%= University.human_attribute_name('invoice_date') %></th>
        <th><%= University.human_attribute_name('contribution_amount') %></th>
        <th></th>
      </tr>
    </thead>
    <tbody>
      <% @universities.each do |university| %>
        <tr>
          <td><%= link_to university, [:server, university] %></td>
          <td><%= link_to university.url, university.url, target: :_blank %></td>
          <td>
            <%= university.private ? University.human_attribute_name('private') :
                                     University.human_attribute_name('public') %>
          </td>
          <td><%= university.languages.count %></td>
          <td><%= link_to university.users.not_server_admin.count, "#{university.url}/admin/users", target: :_blank %></td>
          <% if university.contribution_amount.to_i.zero? %>
            <td></td>
            <td></td>
          <% else %>
            <td class="<%= university.invoice_proximity.blank? ? '' : "table-#{university.invoice_proximity}" %>">
              <%= l(university.invoice_date, format: "%d %B") if university.invoice_date %>
            </td>
            <td class="<%= university.invoice_proximity.blank? ? '' : "table-#{university.invoice_proximity}" %>">
              <%= number_to_currency university.contribution_amount, precision: 0, locale: :fr %>
            </td>
          <% end %>
          <td class="text-end">
            <div class="btn-group" role="group">
              <%= link_to t('edit'),
                        [:edit, :server, university],
                        class: button_classes %>
              <%= link_to t('delete'),
                        [:server, university],
                        method: :delete,
                        data: { confirm: t('please_confirm') },
                        class: button_classes_danger %>
            </div>
          </td>
        </tr>
      <% end %>
    </tbody>
    <tfoot>
      <tr>
        <th class="text-start" colspan="6"><%= t('server_admin.universities.contributions_total') %></th>
        <td class="text-start" colspan="2"><%= number_to_currency University.sum(:contribution_amount), precision: 0, locale: :fr %></td>
      </tr>
    </tfoot>
  </table>
</div>

<%= paginate @universities %>

<% content_for :action_bar_right do %>
  <%= link_to t('create'), new_server_university_path, class: button_classes %>
<% end %>