mysociety/alaveteli

View on GitHub
app/views/admin_public_body/show.html.erb

Summary

Maintainability
Test Coverage
<% @title = "Public authority – #{ @public_body.name }" %>

<h1><%= @title %></h1>

<table class="table table-striped table-condensed">
  <tbody>
    <% @public_body.for_admin_column do |name, value| %>
      <% unless (name == 'api_key' && cannot?(:read, :api_key)) %>
        <tr>
          <td>
            <b><%= name.humanize %></b>
          </td>

          <td>
            <% if ['home_page', 'publication_scheme', 'disclosure_log'].include? name %>
              <% if value %>
                <%= link_to h(value), value  %>
              <% end %>
            <% elsif name == 'request_email' %>
              <%= link_to(h(value), "mailto:#{value}")  %>
              <% unless @public_body.is_requestable? %>
                <%= "not requestable due to: #{ @public_body.not_requestable_reason }" %><% if @public_body.is_followupable? %>; but followupable<% end %>
              <% end %>
            <% elsif name == 'notes' %>
              <%=h @public_body.legacy_note&.body %>
            <% else %>
              <%=h value %>
            <% end %>
          </td>
        </tr>
      <% end %>
    <% end %>

    <tr>
      <td>
        <b>Calculated home page</b>
      </td>

      <td>
        <% unless @public_body.calculated_home_page.nil? %>
          <%= link_to(h(@public_body.calculated_home_page), @public_body.calculated_home_page) %>
        <% else %>
          *unknown*
        <% end %>
      </td>
    </tr>

    <tr>
      <td>
        <b>Tags</b>
      </td>

      <td>
        <%= render_tags @public_body.tags %>
      </td>
    </tr>
  </tbody>
</table>

<%= link_to 'Edit', edit_admin_body_path(@public_body), class: 'btn btn-primary' %>

<% unless @public_body.url_name.nil? %>
  <%= link_to 'Public page', public_body_path(@public_body), class: 'btn' %>
<% else %>
  Public page not available
<% end %>

<hr>

<h2>History</h2>

<% @versions.each_with_index do |version, i| %>
  <div class="row">
    <div class="span2">
      <b>
        <%= "Version #{ version.version }" %>
      </b>
    </div>

    <div class="span4">
      <%= version.updated_at.to_fs(:db) %>
      (<%= time_ago_in_words(version.updated_at) %> ago)
    </div>

    <div class="span6">
      <p>
        “<%= h(version.last_edit_comment) %>”

        <% if version.editor %>
          – <%= link_to version.editor.name, admin_user_path(version.editor) %>
        <% else %>
          – <%= version.last_edit_editor %>
        <% end %>
      </p>

      <% if i == @versions.length - 1 %>
        <ul>
          <li>This is the first version.</li>
        </ul>
      <% else %>
        <ul>
          <% version.compare(@versions[i+1]) do |change| %>
            <li>
              <%= change[:name] %> was changed from
              <code><%= change.fetch(:from, '-') %></code> to
              <code><%= change.fetch(:to, '-') %></code>
            </li>
          <% end %>
        </ul>
      <% end %>
    </div>
  </div>
<% end %>

<hr>

<h2>Requests</h2>

<%= render partial: 'admin_request/prominence_counts',
           locals: { info_requests: @public_body.info_requests } %>

<%= render :partial => 'admin_request/some_requests', :locals => { :info_requests => @info_requests } %>

<hr>

<h2>Track things</h2>

<%= render :partial => 'admin_track/some_tracks', :locals => { :track_things => @public_body.track_things, :include_destroy => true } %>

<hr>

<h2>Censor rules</h2>

<%= render partial: 'admin_censor_rule/list',
           locals: { censor_rules: @public_body.censor_rules,
                     public_body: @public_body } %>

<hr>

<h2>Notes</h2>

<%= render partial: 'admin/notes/show',
  locals: { notes: @public_body.all_notes,
            notable: @public_body } %>