aboutsummaryrefslogtreecommitdiffstats
path: root/app/views/admin_track/_some_tracks.rhtml
blob: 8ae7bd5c124e4c699ec1fc4c27b1fe296750f548 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<% include_destroy = include_destroy || false %>
<% if track_things.empty? %>
  <div class="row">
    <div class="span12">
      <%=_("No tracked things found.")%>
    </div>
  </div>
<% else %>
  <div class="accordion" id="tracks">
    <% for track_thing in track_things %>
      <div class="accordion-group">
        <div class="accordion-heading">
          <a href="#track_<%=track_thing.id%>" data-toggle="collapse" data-parent="requests"><i class="icon-chevron-right"></i></a>
          <%=track_thing.id%>:
          <% if track_thing.public_body_id %>
            <%= link_to "<code>#{h track_thing.track_query}</code>".html_safe, public_body_path(track_thing.public_body) %>
          <% elsif track_thing.info_request_id %>
            <%= link_to "<code>#{h track_thing.track_query}</code>".html_safe, request_path(track_thing.info_request) %>
          <% elsif track_thing.tracked_user_id %>
            <%= link_to "<code>#{h track_thing.track_query}</code>".html_safe, user_path(track_thing.tracked_user) %>
          <% else %>
            <code><%=h track_thing.track_query%></code>
          <% end %>
          <% if @admin_user.nil? %>
            <%# Do not show this on the list of tracks on the user page, because it’s rather repetitive there %>
            tracked by <%=link_to '<i class="icon-eye-open"></i>'.html_safe, admin_user_show_path(track_thing.tracking_user) %> <%=link_to h(track_thing.tracking_user.name), user_path(track_thing.tracking_user) %>
          <% end %>
        </div>
        <div id="track_<%=track_thing.id%>" class="accordion-body collapse">
          <table class="table table-striped table-condensed">
            <tbody>
              <% if include_destroy %>
                <tr>
                  <td colspan="2">
                    <% form_tag '../../user/destroy_track', :class => "form form-inline admin-table-form" do %>
                      <div>
                        <%= hidden_field_tag 'track_id', track_thing.id %>
                        <%= submit_tag "Destroy track", :class => "btn btn-warning" %>
                      </div>
                    <% end %>
                  </td>
                </tr>

              <% end %>
              <% TrackThing.content_columns.each do |column| %>
              <tr>
                <td>
                  <b><%=column.human_name%></b>
                </td>
                <td>
                  <% if column.type.to_s == 'datetime' %>
                    <%= I18n.l(track_thing.send(column.name), :format => "%e %B %Y %H:%M:%S") %>
                    (<%= _('{{length_of_time}} ago', :length_of_time => time_ago_in_words(track_thing.send(column.name))) %>)
                  <% elsif column.name == 'track_medium' and track_thing.track_medium == 'feed' %>
                    <%= link_to track_thing.track_medium, atom_feed_path(:track_id => track_thing.id) %>
                  <% else %>
                    <%= h track_thing.send(column.name)%>
                  <% end %>
                </td>
              </tr>
              <% end %>
              <tr>
                <td><b><%=_("Items sent in last month")%></b></td>
                <td><%= track_thing.track_things_sent_emails.size %></td>
              </tr>
            </tbody>
          </table>
        </div>
      </div>
    <% end %>
  </div>
<% end %>