aboutsummaryrefslogtreecommitdiffstats
path: root/app/views/request
diff options
context:
space:
mode:
Diffstat (limited to 'app/views/request')
-rw-r--r--app/views/request/_correspondence.rhtml68
-rw-r--r--app/views/request/_followup.rhtml5
-rw-r--r--app/views/request/describe_state.rhtml9
-rw-r--r--app/views/request/show.rhtml4
-rw-r--r--app/views/request/show_response.rhtml4
5 files changed, 42 insertions, 48 deletions
diff --git a/app/views/request/_correspondence.rhtml b/app/views/request/_correspondence.rhtml
index 6758bb189..1ff42c5e1 100644
--- a/app/views/request/_correspondence.rhtml
+++ b/app/views/request/_correspondence.rhtml
@@ -1,28 +1,31 @@
<div id="correspondence">
-<% @last_email = nil
-
- if (correspondence.class.to_s == 'IncomingMessage')
- incoming_message = correspondence%>
- <%= render :partial => 'bubble', :locals => { :incoming_message => incoming_message, :body => incoming_message.get_body_for_html_display(@collapse_quotes), :attachments => incoming_message.get_attachments_for_display } %>
+<%
+ @last_email = nil
+ if !info_request_event.nil? && info_request_event.event_type == 'response'
+ incoming_message = IncomingMessage.find(info_request_event.params[:incoming_message_id])
+ end
+
+ if not incoming_message.nil?
+ %>
+ <%= render :partial => 'bubble', :locals => { :incoming_message => incoming_message, :body => incoming_message.get_body_for_html_display(@collapse_quotes), :attachments => incoming_message.get_attachments_for_display } %>
- <p class="event_bubble">
- <% if !incoming_message.safe_mail_from.nil? %>
- <%= incoming_message.safe_mail_from %> of
- <% end %>
- <%= public_body_link(@info_request.public_body) %>
- <% if incoming_message.is_bounce %>
- replied automatically
- <% else %>
- replied
- <% end %>
- on <strong><%= simple_date(incoming_message.sent_at) %></strong>
- (<%= link_to "link to this", show_response_url(:id => incoming_message.info_request.id, :incoming_message_id => incoming_message.id) %>,
- <%= link_to "reply", show_response_url(:id => incoming_message.info_request.id, :incoming_message_id => incoming_message.id) + "#show_response_followup" %>)
- </p>
-<% elsif (correspondence.class.to_s == 'InfoRequestEvent')
- info_request_event = correspondence
- if info_request_event.event_type == 'sent' || info_request_event.event_type == 'followup_sent'
+ <p class="event_bubble">
+ <% if !incoming_message.safe_mail_from.nil? %>
+ <%= incoming_message.safe_mail_from %> of
+ <% end %>
+ <%= public_body_link(@info_request.public_body) %>
+ <% if incoming_message.is_bounce %>
+ replied automatically
+ <% else %>
+ replied
+ <% end %>
+ on <strong><%= simple_date(incoming_message.sent_at) %></strong>
+ (<%= link_to "link to this", show_response_url(:id => incoming_message.info_request.id, :incoming_message_id => incoming_message.id) %>,
+ <%= link_to "reply", show_response_url(:id => incoming_message.info_request.id, :incoming_message_id => incoming_message.id) + "#show_response_followup" %>)
+ </p>
+ <%
+ elsif info_request_event.event_type == 'sent' || info_request_event.event_type == 'followup_sent'
outgoing_message = OutgoingMessage.find(info_request_event.params[:outgoing_message_id])
%>
<%= render :partial => 'bubble', :locals => { :body => outgoing_message.get_body_for_html_display(), :attachments => nil } %>
@@ -33,7 +36,7 @@
<% if outgoing_message.status == 'sent' %>
sent the initial request
to <%= public_body_link(@info_request.public_body) %>
- on <strong><%= simple_date(info_request_event.sent_at) %></strong>
+ on <strong><%= simple_date(info_request_event.created_at) %></strong>
<% elsif outgoing_message.status == 'ready' %>
wrote the initial request, but it has <strong>not yet been sent</strong>
<% else raise "unknown outgoing_message.status" %>
@@ -45,7 +48,7 @@
<%= outgoing_message.incoming_message_followup.safe_mail_from %> of
<% end %>
<%= public_body_link(@info_request.public_body) %>
- on <strong><%= simple_date(info_request_event.sent_at) %></strong>
+ on <strong><%= simple_date(info_request_event.created_at) %></strong>
<% elsif outgoing_message.status == 'ready' %>
wrote a follow up message, but it has <strong>not yet been sent</strong>
<% else raise "unknown outgoing_message.status" %>
@@ -55,19 +58,18 @@
</p>
<% elsif info_request_event.event_type == 'resent' %>
<p class="event_plain">
- Sent to <%= public_body_link(@info_request.public_body) %>
- again (perhaps to a new contact address) <!-- XXX actually say if it is a new one or not -->
- on <strong><%= simple_date(info_request_event.sent_at) %></strong>
+ Sent to <%= public_body_link(@info_request.public_body) %>
+ again (perhaps to a new contact address) <!-- XXX actually say if it is a new one or not -->
+ on <strong><%= simple_date(info_request_event.created_at) %></strong>
</p>
<%
end
- if ['sent', 'resent'].include?(info_request_event.event_type)
- @last_email = info_request_event.params[:email]
+ if !info_request_event.nil?
+ if ['sent', 'resent'].include?(info_request_event.event_type)
+ @last_email = info_request_event.params[:email]
+ end
end
- %>
-<% else %>
- <% raise "Unknown correspondence type " + correspondence.class.to_s %>
-<% end %>
+%>
</div>
diff --git a/app/views/request/_followup.rhtml b/app/views/request/_followup.rhtml
index f228ca71d..8266661c9 100644
--- a/app/views/request/_followup.rhtml
+++ b/app/views/request/_followup.rhtml
@@ -1,8 +1,5 @@
<div id="followup">
-<% if (correspondence.class.to_s == 'IncomingMessage')
- incoming_message = correspondence%>
-
<h2>Send a follow up message
<% if !incoming_message.safe_mail_from.nil? %>
to <%= incoming_message.safe_mail_from %>
@@ -32,7 +29,5 @@
<% end %>
</p>
-<% end %>
-
</div>
diff --git a/app/views/request/describe_state.rhtml b/app/views/request/describe_state.rhtml
index a73bd1611..9f8b4afe8 100644
--- a/app/views/request/describe_state.rhtml
+++ b/app/views/request/describe_state.rhtml
@@ -11,15 +11,12 @@
<h2><%=MySociety::Format.fancy_pluralize(@needing_description.size, 'New response', 'new responses') %>
to your request '<%= request_link @info_request %>'</h2>
- <% for correspondence in @needing_description %>
- <%= render :partial => 'correspondence', :locals => { :correspondence => correspondence } %>
+ <% for incoming_message in @needing_description %>
+ <%= render :partial => 'correspondence', :locals => { :info_request_event => nil, :incoming_message => incoming_message } %>
<% end %>
-
- <div id="show_response_followup">
- <%= render :partial => 'followup', :locals => { :correspondence => @incoming_message } %>
- </div>
</div>
<div id="describe_state_form">
<%= render :partial => 'describe_state' %>
</div>
+
diff --git a/app/views/request/show.rhtml b/app/views/request/show.rhtml
index dc47de333..681e64f4a 100644
--- a/app/views/request/show.rhtml
+++ b/app/views/request/show.rhtml
@@ -48,8 +48,8 @@
<% end %>
</p>
- <% for correspondence in @correspondences %>
- <%= render :partial => 'correspondence', :locals => { :correspondence => correspondence } %>
+ <% for info_request_event in @info_request_events %>
+ <%= render :partial => 'correspondence', :locals => { :info_request_event => info_request_event, :incoming_message => nil } %>
<% end %>
</div>
diff --git a/app/views/request/show_response.rhtml b/app/views/request/show_response.rhtml
index 670dfb08f..8428b7ff7 100644
--- a/app/views/request/show_response.rhtml
+++ b/app/views/request/show_response.rhtml
@@ -13,10 +13,10 @@
<h2>Response to your request '<%= request_link @info_request %>'</h2>
<% end %>
- <%= render :partial => 'correspondence', :locals => { :correspondence => @incoming_message } %>
+ <%= render :partial => 'correspondence', :locals => { :info_request_event => nil, :incoming_message => @incoming_message } %>
<div id="show_response_followup">
- <%= render :partial => 'followup', :locals => { :correspondence => @incoming_message } %>
+ <%= render :partial => 'followup', :locals => { :incoming_message => @incoming_message } %>
</div>
</div>