BathHacked/energy-sparks

View on GitHub
app/views/admin/activations/index.html.erb

Summary

Maintainability
Test Coverage
<h1>Schools awaiting activation</h1>

<p>
  This page lists all schools which are awaiting activation. They are either not yet visible on the system or have not had their data feeds set. The list includes those that were manually setup and those created via the usual onboarding route.
</p>

<p>
 Each table provides a summary of the setup status with access to the key management pages. Click on the school name to view their dashboard and the school management menu.
</p>

<% if @school_groups.any? %>
  <div class="row">
    <div class="col">
      <table class="table table-sorted table-sm table-activations">
        <thead>
          <tr>
            <th class="name">School group</th>
            <th class="name">Group admin</th>
            <th class="name">School name</th>
            <th class="completed">Onboarding completed</th>
            <th class="visible">Visible?</th>
            <th class="processing">Process data?</th>
            <th class="enabled">Data visible?</th>
            <th class="meters">Meters</th>
            <th class="review">Awaiting meter review?</th>
            <th class="review">Issues?</th>
            <th class="actions">Actions</th>
          </tr>
        </thead>
        <tbody>
          <% @school_groups.each do |school_group| %>
            <% school_group.schools.awaiting_activation.by_name.each do |school| %>
              <tr>
                <td><%= link_to school_group.name, admin_school_group_path(school_group) %></td>
                <td><%= school_group.default_issues_admin_user&.name %></td>
                <td><%= link_to school.name, school_path(school) %></td>
                <td>
                    <% if school.school_onboarding.present? %>
                      <%= nice_dates(school.school_onboarding.completed_on) %>
                    <% else %>
                      N/A
                    <% end %>
                </td>
                <td><%= checkmark(school.visible) %></td>
                <td><%= checkmark(school.process_data) %></td>
                <td><%= checkmark(school.data_enabled) %></td>
                <td><%= school.meters.count %></td>
                <td>
                  <%= y_n(school.meters.unreviewed_dcc_meter.any?) %>
                  <% if school.meters.unreviewed_dcc_meter.any? %>
                  <%= link_to '(view)', admin_meter_reviews_path %>
                  <% end %>
                </td>
                <td>
                  <%= if school.issues.status_open.any?
                        link_to school.issues.status_open.count, admin_school_issues_path(school_id: school.slug)
                      end %>
                </td>
                <td>
                  <div class="btn-group">
                    <%= link_to 'Edit details', edit_school_path(school), class: 'btn btn-sm' %>
                    <%= link_to 'Meters', school_meters_path(school), class: 'btn btn-sm' %>
                    <%= link_to 'Users', school_users_path(school), class: 'btn btn-sm' %>
                  </div>
                </td>
              </tr>
            <% end %>
          <% end %>
        </tbody>
      </table>
    </div>

  </div>
<% else %>
  <p>There are no schools currently awaiting activation</p>
<% end %>