mysociety/alaveteli

View on GitHub
app/views/admin_raw_email/_holding_pen.html.erb

Summary

Maintainability
Test Coverage
<div class="holding_pen">
  <p class="lead text-warning">
    This is in the holding pen because: <strong><%= @rejected_reason %></strong>
  </p>

  <% if @public_bodies.size > 0 %>
    <p>Guessed authority <small>(based on From: email domain)</small>:</p>

    <ul class="unstyled">
      <% @public_bodies.each do |public_body| %>
        <li><%= both_links(public_body) %></li>
      <% end %>
    </ul>
  <% end %>

  <% if @guessed_info_requests.any? %>
  <div class="row">
    <div class="accordion span11" id="guessed-requests">
      <p>Guessed request: </p>

      <% if @guessed_info_requests.one? %>
        <p>
          <small class="muted">
            Responses with a single guess are only automatically redelivered if
            the guess meets a confidence threshold. This guess did not meet that
            threshold.
          </small>
        </p>
      <% end %>

      <% @guessed_info_requests.each do |guess|  %>
        <div class="accordion-group">
          <div class="accordion-heading">
            <a href="#info_request_<%= guess.info_request.id %>" data-toggle="collapse"><i class="icon-chevron-right"></i></a>
            <%= both_links(guess.info_request) %>

            <%= guess_badge(guess.id_score) do %>
              ID:
              <%= number_to_percentage(guess.id_score * 100, precision: 0) %>
            <% end %>

            <%= guess_badge(guess.idhash_score) do %>
              Idhash:
              <%= number_to_percentage(guess.idhash_score * 100, precision: 0) %>
            <% end %>
          </div>

          <div class="accordion-body collapse" id="info_request_<%= guess.info_request.id %>">
            <table class="table table-striped table-condensed">
              <tr>
                <td><strong>Last outgoing message:</strong></td>
                <td><%= guess.info_request.outgoing_messages.last.body %></td>
              </tr>

              <tr>
                <td><strong>Created by:</strong></td>
                <td><%= both_links(guess.info_request.user) %></td>
              </tr>

              <tr>
                <td><strong>Authority:</strong></td>
                <td>
                  <%= both_links(guess.info_request.public_body) %>
                </td>
              </tr>

              <tr>
                <td><strong>url_title:</strong></td>
                <td><%= guess.info_request.url_title %></td>
              </tr>

              <tr>
                <td><strong>ID Guess Score:</strong></td>
                <td><%= number_to_percentage(guess.id_score * 100, precision: 0) %></td>
              </tr>

              <tr>
                <td><strong>Idhash Guess Score:</strong></td>
                <td><%= number_to_percentage(guess.idhash_score * 100, precision: 0) %></td>
              </tr>
            </table>

            <p>
              This request was guessed based on
              <code><%= guess.match_method %></code>
              <% if guess.match_method == :subject %>
                because the incoming message has a subject of
                <strong><%= guess[:subject] %></strong>
              <% else %>
                because it has an incoming email address
                of <strong><%= guess.info_request.incoming_email %></strong>
                and this incoming message was sent to
              <strong><%= guess[:email] %></strong>.
              <% end %>

            </p>
          </div>
        </div>
      <% end %>
    </div>
    </div>
  <% end %>
</div>