aboutsummaryrefslogtreecommitdiffstats
path: root/app/views/admin_general/timeline.html.erb
blob: e84539970363c34a8f31c190a2366f0b245d8d6f (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
<% @title = "Timeline" %>

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

<p>
<a href="?hour=1">Hour</a>
| <a href="?day=1">Day</a>
| <a href="?">2 days</a>
| <a href="?week=1">Week</a>
| <a href="?month=1">Month</a>
| <a href="?all=1">All time</a></p>

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

    <%= simple_time(event_at) %>

    <% if event.is_a? InfoRequestEvent %>
        <%= request_both_links(event.info_request) %>
        <% if event.event_type == 'edit' %>
            was edited by administrator <strong><%=h event.params[:editor] %></strong>.
            <% 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_message = OutgoingMessage.find(event.params[:outgoing_message_id].to_i) %>
            had outgoing message edited by administrator <strong><%=h event.params[:editor] %></strong>.
            <% if outgoing_message %>
                <% 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 == 'edit_comment' %>
            <% comment = Comment.find(event.params[:comment_id].to_i) %>
            had annotation edited by administrator <strong><%=h event.params[:editor] %></strong>.
            <% if comment %>
                <% 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 annotation, internal error.
            <% end %>
        <% elsif event.event_type == 'destroy_incoming' %>
            had incoming message deleted by administrator <strong><%=h event.params[:editor] %></strong>.
        <% elsif event.event_type == 'destroy_outgoing' %>
            had outgoing message deleted by administrator <strong><%=h event.params[:editor] %></strong>.
        <% elsif event.event_type == 'hide' %>
            was hidden by administrator <strong><%=h event.params[:editor] %></strong>.
        <% elsif event.event_type == 'redeliver_outgoing' %>
            had incoming message redelivered to another request by administrator <strong><%=h event.params[:editor] %></strong>.
         <% elsif event.event_type == 'response' %>
            <% incoming_message = event.incoming_message %>
            received
            <%= link_to 'a response', main_url(incoming_message_url(incoming_message)) %>
            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 %>.
        <% elsif event.event_type == 'comment' %>
            had an annotation posted by <%=h event.comment.user.name %>.
        <% elsif event.event_type == 'status_update' %>
                had its status updated by <%=h User.find(event.params[:user_id]).name %> from '<%= h event.params[:old_described_state] %>' to '<%= h event.params[:described_state] %>'.
        <% else %>
            had '<%=event.event_type%>' done to it, parameters <%=h event.params_yaml%>.
        <% end %>
    <% else %>
        <%= public_body_both_links(event.public_body) %>
        was created/updated by administrator <strong><%=h event.last_edit_editor %></strong>
    <% end %>
<% end %>
<% if not @events.empty? %>
</p>
<% end %>
<%= will_paginate(@events) %>