BathHacked/energy-sparks

View on GitHub
app/views/admin/users/_other_users.html.erb

Summary

Maintainability
Test Coverage
<h2>Users without a school</h2>

<table class="table table-sm table-sorted">
  <thead>
    <tr>
      <th>Name</th>
      <th>Email</th>
      <th>Role</th>
      <th>Confirmed</th>
      <th>Last sign in</th>
      <th>Locked?</th>
      <th></th>
    </tr>
  </thead>
  <tbody>
    <% @unattached_users.each do |user| %>
      <tr class="<%= 'table-danger' if user.access_locked? %>">
        <td><%= user.name %></td>
        <td><%= user.pupil? ? "N/A" : user.email %></td>
        <td><%= user.role.titleize %></td>
        <td><%= y_n(user.confirmed?) %></td>
        <td data-order="<%=user.last_sign_in_at.iso8601 if user.last_sign_in_at %>"><%= display_last_signed_in_as(user) %></td>
        <td><%= y_n(user.access_locked?) %></td>
        <td>
          <div class="btn-group">
            <%= link_to 'Edit', edit_admin_user_path(user), class: 'btn btn-primary btn-sm' %>
            <%= link_to 'Delete', admin_user_path(user), method: :delete, data: { confirm: 'Are you sure?' }, class: 'btn btn-danger btn-sm' %>
            <%= button_to 'Resend confirmation', admin_user_confirmation_path(user), class: 'btn btn-warning btn-sm' unless user.confirmed? %>
            <%= link_to 'Unlock', admin_user_unlock_path(user_id: user.id), class: 'btn btn-warning btn-sm' if user.access_locked? %>
          </div>
        </td>
      </tr>
    <% end %>
  </tbody>
</table>