diff options
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/info_request.rb | 22 | ||||
-rw-r--r-- | app/models/info_request_event.rb | 62 |
2 files changed, 54 insertions, 30 deletions
diff --git a/app/models/info_request.rb b/app/models/info_request.rb index ff00235ed..0b038bc25 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.153 2008-11-07 00:01:50 francis Exp $ +# $Id: info_request.rb,v 1.154 2008-11-10 11:18:39 francis Exp $ require 'digest/sha1' require File.join(File.dirname(__FILE__),'../../vendor/plugins/acts_as_xapian/lib/acts_as_xapian') @@ -372,7 +372,7 @@ public def calculate_event_states curr_state = nil for event in self.info_request_events.reverse - if not event.described_state.nil? and curr_state.nil? + if !event.described_state.nil? && curr_state.nil? curr_state = event.described_state #STDERR.puts "curr_state " + curr_state end @@ -389,10 +389,20 @@ public end curr_state = nil elsif !curr_state.nil? && event.event_type == 'followup_sent' && !event.described_state.nil? && (event.described_state == 'waiting_response' || event.described_state == 'internal_review') - # followups can set the status to waiting response / internal - # review, which we don't want to propogate to the response - # itself, as that might already be set to waiting_clarification - # / a success status, which we want to know about. + # Followups can set the status to waiting response / internal + # review. + + # We want to store that in calculated_state state so it gets + # indexed. + if event.calculated_state != event.described_state + event.calculated_state = event.described_state + event.last_described_at = Time.now() + event.save! + end + + # And we don't want to propogate it to the response itself, + # as that might already be set to waiting_clarification / a + # success status, which we want to know about. curr_state = nil end end diff --git a/app/models/info_request_event.rb b/app/models/info_request_event.rb index 8595e3669..d16571d1a 100644 --- a/app/models/info_request_event.rb +++ b/app/models/info_request_event.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: info_request_event.rb,v 1.67 2008-11-06 14:53:07 francis Exp $ +# $Id: info_request_event.rb,v 1.68 2008-11-10 11:18:39 francis Exp $ class InfoRequestEvent < ActiveRecord::Base belongs_to :info_request @@ -194,31 +194,45 @@ class InfoRequestEvent < ActiveRecord::Base # Display version of status def display_status - if incoming_message.nil? - raise "display_status only works for incoming messages right now" - end - status = self.calculated_state - if status == 'waiting_response' - "Acknowledgement" - elsif status == 'waiting_clarification' - "Clarification required" - elsif status == 'gone_postal' - "Handled by post" - elsif status == 'not_held' - "Information not held" - elsif status == 'rejected' - "Rejection" - elsif status == 'partially_successful' - "Some information sent" - elsif status == 'successful' - "All information sent" - elsif status == 'internal_review' - "Internal review acknowledgement" - elsif status == 'requires_admin' - "Unusual response" - else + if !incoming_message.nil? + status = self.calculated_state + if status == 'waiting_response' + return "Acknowledgement" + elsif status == 'waiting_clarification' + return "Clarification required" + elsif status == 'gone_postal' + return "Handled by post" + elsif status == 'not_held' + return "Information not held" + elsif status == 'rejected' + return "Rejection" + elsif status == 'partially_successful' + return "Some information sent" + elsif status == 'successful' + return "All information sent" + elsif status == 'internal_review' + return "Internal review acknowledgement" + elsif status == 'requires_admin' + return "Unusual response" + end raise "unknown status " + status end + + if !outgoing_message.nil? + status = self.calculated_state + if !status.nil? + if status == 'internal_review' + return "Internal review request" + end + if status == 'waiting_response' + return "Clarification" + end + raise "unknown status " + status + end + return "Follow up" + end + + raise "display_status only works for incoming and outgoing messages right now" end def is_sent_sort? |