mysociety/alaveteli

View on GitHub
app/views/admin_censor_rule/_list.html.erb

Summary

Maintainability
Test Coverage
<div class="row">
  <div class="span12 help-block">
    <p>
      Each rule applies sequentially to the text after having been modified by
      the previous rule, so the order may matter depending on what you are
      trying to redact.
    </p>
  </div>
</div>

<div class="row">
  <% if censor_rules.size > 0 %>
    <table class="table table-condensed table-hover span12 censor-rule-list">
      <tr>
        <th>Id</th>
        <% CensorRule.content_columns.each do |column| %>
          <th><%= column.name.humanize %></th>
        <% end %>
        <th>Applies to</th>
        <th>Actions</th>
      </tr>

      <% censor_rules.each do |censor_rule| %>
        <tr class="<%= cycle('odd', 'even') %>">
          <td class="id"><%=h censor_rule.id %></td>

          <% CensorRule.content_columns.map { |c| c.name }.each do |column| %>
            <td class="<%= column %>"><%=h censor_rule.send(column) %></td>
          <% end %>

          <td class="applies-to">
            <%= censor_rule_applicable_class(censor_rule) %>
          </td>

          <td>
            <%= link_to "Edit", edit_admin_censor_rule_path(censor_rule) %>
          </td>
        </tr>
      <% end %>
    </table>
  <% else %>
    <p class="span12">None yet.</p>
  <% end %>
</div>

<div class="row">
  <p class="span12">
    <% if defined? info_request %>
      <%= link_to "New censor rule", new_admin_request_censor_rule_path(info_request), :class => "btn btn-info" %>
      <span class="help-inline">for this request only</span>
    <% end %>

    <% if defined? user %>
      <%= link_to "New censor rule", new_admin_user_censor_rule_path(user), :class => "btn btn-info" %>
      <span class="help-inline">for all requests by this user</span>
    <% end %>

    <% if defined? public_body %>
      <%= link_to "New censor rule", new_admin_body_censor_rule_path(public_body), :class => "btn btn-info" %>
      <span class="help-inline">for all requests to this body</span>
    <% end %>

    <% unless defined?(info_request) || defined?(user) || defined?(public_body) %>
      <%= link_to "New global censor rule", new_admin_censor_rule_path, :class => "btn btn-warning" %>
      <span class="help-inline">for all requests, users and bodies</span>
    <% end %>
  </p>
</div>