aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/controllers/request_controller.rb10
-rw-r--r--app/models/info_request.rb13
-rw-r--r--app/models/info_request_event.rb10
-rw-r--r--app/views/admin_request/show.rhtml2
-rw-r--r--app/views/layouts/default.rhtml1
-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
10 files changed, 58 insertions, 68 deletions
diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb
index 9e06a027b..f732cf687 100644
--- a/app/controllers/request_controller.rb
+++ b/app/controllers/request_controller.rb
@@ -4,14 +4,14 @@
# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved.
# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
#
-# $Id: request_controller.rb,v 1.42 2008-01-29 03:05:46 francis Exp $
+# $Id: request_controller.rb,v 1.43 2008-02-01 15:27:48 francis Exp $
class RequestController < ApplicationController
def show
@info_request = InfoRequest.find(params[:id])
- @correspondences = @info_request.incoming_messages + @info_request.info_request_events
- @correspondences.sort! { |a,b| a.sent_at <=> b.sent_at }
+ @info_request_events = @info_request.info_request_events
+ @info_request_events.sort! { |a,b| a.created_at <=> b.created_at }
@status = @info_request.calculate_status
@date_response_required_by = @info_request.date_response_required_by
@collapse_quotes = params[:unfold] ? false : true
@@ -164,8 +164,8 @@ class RequestController < ApplicationController
if !@outgoing_message.valid?
render :action => 'show_response'
elsif authenticated_as_user?(@info_request.user,
- :web => "To send a follow up message about your FOI request",
- :email => "Then you can send a follow up message to " + @info_request.public_body.name + ".",
+ :web => "To send your follow up message about your FOI request",
+ :email => "Then your follow up message to " + @info_request.public_body.name + " will be sent.",
:email_subject => "Confirm your FOI follow up message to " + @info_request.public_body.name
)
# Send a follow up message
diff --git a/app/models/info_request.rb b/app/models/info_request.rb
index 5ff0b3a1c..8743a8572 100644
--- a/app/models/info_request.rb
+++ b/app/models/info_request.rb
@@ -20,7 +20,7 @@
# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved.
# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
#
-# $Id: info_request.rb,v 1.32 2008-01-30 09:53:47 francis Exp $
+# $Id: info_request.rb,v 1.33 2008-02-01 15:27:49 francis Exp $
require 'digest/sha1'
@@ -102,6 +102,7 @@ public
incoming_message.save!
self.awaiting_description = true
+ self.log_event("response", { :incoming_message_id => incoming_message.id })
self.save!
end
@@ -155,7 +156,7 @@ public
# Possibly just show 20 working days since the *last* message? Hmmm.
earliest_sent = self.outgoing_messages.map { |om| om.last_sent_at }.min
if earliest_sent.nil?
- raise "internal error, minimum last_sent_at for outgoing_messages is nil for request " + self.id.to_s
+ raise "internal error, minimum last_sent_at for outgoing_messages is nil for request " + self.id.to_s + " outgoing messages count " + self.outgoing_messages.size.to_s
end
days_passed = 0
@@ -227,12 +228,12 @@ public
# Returns all the messages which the user hasn't described yet
def incoming_messages_needing_description
if self.described_last_incoming_message_id.nil?
- correspondences = self.incoming_messages.find(:all)
+ incoming_messages = self.incoming_messages.find(:all)
else
- correspondences = self.incoming_messages.find(:all, :conditions => "id > " + self.described_last_incoming_message_id.to_s)
+ incoming_messages = self.incoming_messages.find(:all, :conditions => "id > " + self.described_last_incoming_message_id.to_s)
end
- correspondences.sort! { |a,b| a.sent_at <=> b.sent_at }
- return correspondences
+ incoming_messages.sort! { |a,b| a.sent_at <=> b.sent_at }
+ return incoming_messages
end
protected
diff --git a/app/models/info_request_event.rb b/app/models/info_request_event.rb
index 0b5ac64f5..f291daca5 100644
--- a/app/models/info_request_event.rb
+++ b/app/models/info_request_event.rb
@@ -15,7 +15,7 @@
# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved.
# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
#
-# $Id: info_request_event.rb,v 1.8 2008-01-29 01:26:21 francis Exp $
+# $Id: info_request_event.rb,v 1.9 2008-02-01 15:27:49 francis Exp $
class InfoRequestEvent < ActiveRecord::Base
belongs_to :info_request
@@ -28,7 +28,8 @@ class InfoRequestEvent < ActiveRecord::Base
'followup_sent',
'followup_resent',
'edit_outgoing', # outgoing message edited in admin interface
- 'manual' # you did something in the db by hand
+ 'manual', # you did something in the db by hand
+ 'response'
]
# We store YAML version of parameters in the database
@@ -39,11 +40,6 @@ class InfoRequestEvent < ActiveRecord::Base
YAML.load(self.params_yaml)
end
- # Used for sorting with the incoming/outgoing messages
- def sent_at
- created_at
- end
-
end
diff --git a/app/views/admin_request/show.rhtml b/app/views/admin_request/show.rhtml
index 1dd82dc6e..6e4c432d6 100644
--- a/app/views/admin_request/show.rhtml
+++ b/app/views/admin_request/show.rhtml
@@ -73,7 +73,7 @@
<% end %>
</tr>
-<% for info_request_event in @info_request.info_request_events %>
+<% for info_request_event in @info_request.info_request_events.find(:all, :order => "created_at, id") %>
<tr class="<%= cycle('odd', 'even') %>">
<% for column in InfoRequestEvent.content_columns.map { |c| c.name } %>
<td><%=h info_request_event.send(column) %></td>
diff --git a/app/views/layouts/default.rhtml b/app/views/layouts/default.rhtml
index 02398dc01..f3437b8dd 100644
--- a/app/views/layouts/default.rhtml
+++ b/app/views/layouts/default.rhtml
@@ -21,7 +21,6 @@
<% else %>
<% end %>
<li><%= link_to "About", about_url %></li>
- <!-- <li><a href="/about">About</a></li> -->
</ul>
<% if MySociety::Config.getbool("STAGING_SITE", 1) %>
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>