BathHacked/energy-sparks

View on GitHub
app/views/schools/users/_users.html.erb

Summary

Maintainability
Test Coverage
<table class="table table-condensed">
  <thead>
    <tr>
      <th><%= t('schools.users.index.name') %></th>
      <th><%= t('schools.users.index.email') %></th>
      <th><%= t('schools.users.index.account_confirmed') %></th>
      <th><%= t('schools.users.index.receives_alerts') %></th>
      <th><%= t('schools.users.index.role') %></th>
      <th><%= t('schools.users.index.preferred_locale') %></th>
      <th></th>
    </tr>
  </thead>

  <tbody>
    <% users.each do |user| %>
      <tr>
          <td><%= user.name %></td>
          <td><%= user.email %></td>
          <td><%= y_n(user.confirmed?) %></td>
          <td><%= y_n(user.contacts.for_school(@school).present?) %></td>
          <td><%= user.staff_role.try(:translated_title) %></td>
          <td><%= I18n.t("languages.#{user.preferred_locale}") %></td>
          <td>
            <div class="btn-group nowrap">
              <%= link_to(t('common.labels.edit'), edit_school_user_path(@school, user), class: 'btn btn-primary btn-sm') if can?(:edit, user) %>
              <%= link_to(t('common.labels.delete'), school_user_path(@school, user), method: :delete, data: { confirm: t('common.confirm') }, class: 'btn btn-danger btn-sm') if can?(:delete, user) %>
              <% if current_user.admin? && !user.confirmed? %>
                <%= button_to t('schools.users.index.resend_confirmation'), admin_user_confirmation_path(user, school: true), class: 'btn btn-warning btn-sm' %>
              <% end %>
              <% if can?(:edit, user) && !user.school_admin? %>
                <%= link_to(t('schools.users.index.make_school_admin'), make_school_admin_school_user_path(@school, user), method: :post, data: { confirm: t('common.confirm') }, class: 'btn btn-danger btn-sm') %>
              <% end %>
            </div>
          </td>
      </tr>
    <% end %>
  </tbody>
</table>