diff options
-rw-r--r-- | app/models/info_request.rb | 11 | ||||
-rw-r--r-- | app/models/info_request_event.rb | 29 | ||||
-rw-r--r-- | app/models/outgoing_message.rb | 4 | ||||
-rw-r--r-- | app/views/request/_correspondence.rhtml | 16 | ||||
-rw-r--r-- | todo.txt | 5 |
5 files changed, 47 insertions, 18 deletions
diff --git a/app/models/info_request.rb b/app/models/info_request.rb index e9a366d36..e6ac03d72 100644 --- a/app/models/info_request.rb +++ b/app/models/info_request.rb @@ -23,7 +23,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.128 2008-08-13 09:51:45 francis Exp $ +# $Id: info_request.rb,v 1.129 2008-08-20 23:56:21 francis Exp $ require 'digest/sha1' require File.join(File.dirname(__FILE__),'../../vendor/plugins/acts_as_xapian/lib/acts_as_xapian') @@ -396,12 +396,15 @@ public expecting_clarification = true end - if [ 'sent', 'resent', 'followup_sent' ].include?(event.event_type) + if [ 'sent', 'resent', 'followup_sent', 'followup_resent' ].include?(event.event_type) if last_sent.nil? last_sent = event elsif event.event_type == 'resent' last_sent = event elsif expecting_clarification and event.event_type == 'followup_sent' + # XXX this needs to cope with followup_resent, which it doesn't. + # Not really easy to do, and only affects cases where followups + # were resent after a clarification. last_sent = event expecting_clarification = false end @@ -524,7 +527,7 @@ public # The last outgoing message def get_last_outgoing_event for e in self.info_request_events.reverse - if e.event_type == 'sent' || e.event_type == 'resent' || e.event_type == 'followup_sent' + if [ 'sent', 'resent', 'followup_sent', 'followup_resent' ].include?(e.event_type) return e end end @@ -578,7 +581,7 @@ public def get_previous_email_sent_to(info_request_event) last_email = nil for e in self.info_request_events - if (e.event_type == 'sent' || e.event_type == 'resent') && e.outgoing_message_id == info_request_event.outgoing_message_id + if ((info_request_event.is_sent_sort? && e.is_sent_sort?) || (info_request_event.is_followup_sort? && e.is_followup_sort?)) && e.outgoing_message_id == info_request_event.outgoing_message_id if e.id == info_request_event.id break end diff --git a/app/models/info_request_event.rb b/app/models/info_request_event.rb index eb1cb98d8..48015500a 100644 --- a/app/models/info_request_event.rb +++ b/app/models/info_request_event.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_event.rb,v 1.51 2008-08-13 01:39:41 francis Exp $ +# $Id: info_request_event.rb,v 1.52 2008-08-20 23:56:21 francis Exp $ class InfoRequestEvent < ActiveRecord::Base belongs_to :info_request @@ -38,6 +38,7 @@ class InfoRequestEvent < ActiveRecord::Base 'sent', 'resent', 'followup_sent', + 'followup_resent', 'edit', # title etc. edited in admin interface 'edit_outgoing', # outgoing message edited in admin interface 'destroy_incoming', # deleted an incoming message @@ -171,6 +172,32 @@ class InfoRequestEvent < ActiveRecord::Base raise "unknown status " + status end end + + def is_sent_sort? + if [ 'sent', 'resent'].include?(self.event_type) + return true + end + return false + end + def is_followup_sort? + if [ 'followup_sent', 'followup_resent'].include?(self.event_type) + return true + end + return false + end + + def same_email_as_previous_send? + prev_addr = self.info_request.get_previous_email_sent_to(self) + curr_addr = self.params[:email] + if prev_addr.nil? && curr_addr.nil? + return true + end + if prev_addr.nil? || curr_addr.nil? + return false + end + return TMail::Address.parse(prev_addr).address == TMail::Address.parse(curr_addr).address + end + end diff --git a/app/models/outgoing_message.rb b/app/models/outgoing_message.rb index d02037374..f5bca3669 100644 --- a/app/models/outgoing_message.rb +++ b/app/models/outgoing_message.rb @@ -21,7 +21,7 @@ # Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ # -# $Id: outgoing_message.rb,v 1.58 2008-08-09 15:19:01 francis Exp $ +# $Id: outgoing_message.rb,v 1.59 2008-08-20 23:56:21 francis Exp $ class OutgoingMessage < ActiveRecord::Base belongs_to :info_request @@ -132,7 +132,7 @@ class OutgoingMessage < ActiveRecord::Base # An admin function def resend_message - if self.message_type == 'initial_request' and self.status == 'sent' + if ['initial_request', 'followup'].include?(self.message_type) and self.status == 'sent' self.status = 'ready' send_message('resent') else diff --git a/app/views/request/_correspondence.rhtml b/app/views/request/_correspondence.rhtml index cb58756bf..2d166b636 100644 --- a/app/views/request/_correspondence.rhtml +++ b/app/views/request/_correspondence.rhtml @@ -1,5 +1,4 @@ <% -@last_email = nil if !info_request_event.nil? && info_request_event.event_type == 'response' incoming_message = info_request_event.incoming_message end @@ -50,7 +49,7 @@ elsif info_request_event.event_type == 'sent' || info_request_event.event_type = <%= link_to "Send follow up", show_response_no_followup_url(:id => outgoing_message.info_request.id, :incoming_message_id => nil) + "#show_response_followup" %> </p> </div> -<% elsif info_request_event.event_type == 'resent' %> +<% elsif [ 'resent', 'followup_resent' ].include?(info_request_event.event_type) %> <div class="correspondence"> <h2> <%= simple_date(info_request_event.created_at) %> @@ -60,13 +59,13 @@ elsif info_request_event.event_type == 'sent' || info_request_event.event_type = <% if info_request_event.outgoing_message.message_type == 'initial_request' %> request <% elsif info_request_event.outgoing_message.message_type == 'followup' %> - followup + a follow up <% else %> <% raise "unknown message_type" %> <% end %> - - to <%= public_body_link(@info_request.public_body) %> again<% if @info_request.get_previous_email_sent_to(info_request_event) != info_request_event.params[:email] %>, using a new contact address<% end %>. - </p> + + to <%= public_body_link(@info_request.public_body) %> again<% if not info_request_event.same_email_as_previous_send? %>, using a new contact address<% end %>. + </p> </div> <% elsif info_request_event.event_type == 'comment' comment = info_request_event.comment @@ -83,9 +82,4 @@ elsif info_request_event.event_type == 'sent' || info_request_event.event_type = <% end -if !info_request_event.nil? - if ['sent', 'resent'].include?(info_request_event.event_type) - @last_email = info_request_event.params[:email] - end -end %> @@ -85,6 +85,11 @@ Clear out all the need classifying requests Later ===== +From an email, isn't stripping spaces right. + "Met Office sent a response to Andrew Montford (14 August 2008)" +Also should group by the request id for search queries (so all appear +together when request and response mention same term) + This doesn't work: http://www.whatdotheyknow.com/search/status:waiting_classification/ |