holderdeord/hdo-site

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

Summary

Maintainability
Test Coverage
<% page_title "#{Representative.model_name.human(count: 2).capitalize} - Admin - #{t('app.title')}" %>

<div class="row">
  <div class="span2">
    <h5>Farger</h5>
    <table class="table table-condensed">
      <tr class="success"><td><small>Godtatt invitasjon</small></td></tr>
      <tr class="error"><td><small>Meldt seg ut</small></td></tr>
      <tr class="warning"><td><small>Invitasjon sendt</small></td></tr>
      <tr class="info"><td><small>Ikke invitert</small></td></tr>
    </table>
  </div>
</div>

<table class="table table-condensed table-hover">
  <thead>
    <th>#</th>
    <th><%= Representative.human_attribute_name :name %></th>
    <th><%= Representative.human_attribute_name :party %></th>
    <th><%= Representative.human_attribute_name :email %></th>
    <th><%= Representative.human_attribute_name :twitter_id %></th>
    <th><%= Representative.human_attribute_name :attending %></th>
    <th></th>
    <th><%= t('app.questions_and_answers.short') %></th>
  </thead>
  <tbody>
    <% @representatives.each do |rep| %>
      <tr class="<%= row_class_for_admin_representative(rep) %>">
        <td><%= link_to rep.external_id, rep %></td>
        <td><%= rep.display_name %></td>
        <td><%= rep.latest_party.external_id  %></td>
        <td><%= link_to rep.email, "mailto:#{rep.email}" if rep.email %></td>
        <td><%= link_to rep.twitter_id, rep.twitter_url if rep.twitter_id %> </td>
        <td><%= t(rep.attending? ? 'app.yes' : 'app.no') %></td>
        <td><%= link_to t('app.edit'), edit_admin_representative_path(rep), class: 'btn btn-small', disabled: !policy(rep).edit? %></td>
        <td>
          <% if rep.confirmed? %>
            <%= link_to t('app.questions_and_answers.representative.forgot_password'),
                        admin_representative_reset_password_path(rep),
                        class: 'btn btn-small',
                        disabled: !policy(rep).edit? %>
          <% elsif rep.confirmation_sent_at %>
            <%= link_to t('app.questions_and_answers.representative.reactivate'),
                        admin_representative_activate_path(rep),
                        class: 'btn btn-small',
                        disabled: !policy(rep).edit?,
                        confirm: 'Er du sikker på at du vil sende aktiveringsepost til representanten?' %>
          <% else %>
            <%= link_to t('app.questions_and_answers.representative.activate'),
                        admin_representative_activate_path(rep),
                        class: 'btn btn-small',
                        disabled: !policy(rep).edit?,
                        confirm: 'Er du sikker på at du vil sende aktiveringsepost til representanten?' %>
          <% end %>
        </td>
      </tr>
    <% end %>
  </tbody>
</table>