aboutsummaryrefslogtreecommitdiffstats
path: root/app/views/admin/index.rhtml
blob: cf5e9aff4af1baad4b3c75690473cc63b18d11e0 (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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
<% @title = "Overview" %>

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

<ul>
<li><%=@public_body_count%> public bodies</li>
<li><%=@info_request_count%> requests</li>
<li><%=@user_count%> users</li>
</ul>

<hr>

<% if @requires_admin_requests.size > 0 %>
    <h3>Requests requiring admin attention</h3>

    <ul>
    <% for @request in @requires_admin_requests %>
        <li><%= link_to h(@request.title), "request/show/" + @request.id.to_s %></li>
    <% end %>
    </ul>
<% end %>

<% if @two_week_old_unclassified.size > 0 %>
    <h3>Still unclassified two weeks after response</h3>

    <ul>
    <% for @request in @two_week_old_unclassified %>
        <li><%= link_to h(@request.title), "request/show/" + @request.id.to_s %></li>
    <% end %>
    </ul>
<% end %>

<% if @blank_contacts.size > 0 %>
    <h3>Public bodies with missing contact details</h3>
    <ul>
    <% for @blank_contact in @blank_contacts %>
        <li><%= link_to h(@blank_contact.name), "body/show/" + @blank_contact.id.to_s %></li>
    <% end %>
    </ul>
<% end %>

<% if @requires_admin_requests.size == 0 and @two_week_old_unclassified.size == 0 and @blank_contacts.size == 0 %>
    No pending administration required.
<% end %>

<hr>

<h2><%=h @events_title%></h2>

<p><a href="?">Week</a>
| <a href="?month=1">Month</a>
| <a href="?all=1">All time</a></p>

<% last_date = nil %>
<% for event in @events %>
    <% if last_date != event.created_at.to_date %>
        <% if last_date.nil? %>
            <p>
        <% end %>
        <h3><%= simple_date(event.created_at) %></h3>
        <p>
    <% else %>
        <br>
    <% end %>
    <% last_date = event.created_at.to_date %>


    '<%= link_to h(event.info_request.title), main_url(request_url(event.info_request)) %>'
    <% if event.event_type == 'edit' %>
        was edited by administrator <%=h event.params[:editor] %>.
        <% for p in ['title', 'prominence', 'described_state', 'awaiting_description'] 
                if event.params[p.to_sym] != event.params[('old_'+p).to_sym]
                    %> Changed <%=p%> from '<%=h event.params[('old_'+p).to_sym]%>' to '<%=h event.params[p.to_sym] %>'. <%
                end
           end
        %>
    <% elsif event.event_type == 'edit_outgoing' %>
        <% outgoing_messages = OutgoingMessage.find(:all, event.params[:outgoing_message_id].to_i) %>
        had outgoing message edited by administrator <%=h event.params[:editor] %>.
        <% if outgoing_messages.size > 0 %>
            <% outgoing_message = outgoing_messages[0] %>
            <% for p in ['body'] 
                    if event.params[p.to_sym] != event.params[('old_'+p).to_sym]
                        %> Changed <%=p%> from '<%=h event.params[('old_'+p).to_sym]%>' to '<%=h event.params[p.to_sym] %>'. <%
                    end
               end
            %>
        <% else %>
            Missing outgoing message, internal error.
        <% end %>
    <% elsif event.event_type == 'response' %>
        <% incoming_message = event.incoming_message %>
        received 
        <%= link_to 'a response', 
            main_url(show_response_url(:id => incoming_message.info_request.id, :incoming_message_id => incoming_message.id, :only_path => true)) %>

        from <%=h event.info_request.public_body.name %>.
    <% elsif event.event_type == 'sent' %>
        was initially sent to <%=h event.params[:email]%> at <%=h event.info_request.public_body.name %>.
    <% elsif event.event_type == 'resent' %>
        had the request resent to <%=h event.params[:email]%> at <%=h event.info_request.public_body.name %>.
    <% elsif event.event_type == 'followup_sent' %>
        had a follow up message sent to <%=h event.info_request.public_body.name %>.
    <% else %>
        had '<%=event.event_type%>' done to it, parameters <%=h event.params_yaml%>.
    <% end %>
<% end %>
<% if not @events.empty? %>
</p>
<% end %>