aboutsummaryrefslogtreecommitdiffstats
path: root/app/models/info_request.rb
diff options
context:
space:
mode:
authorfrancis <francis>2008-03-24 09:35:23 +0000
committerfrancis <francis>2008-03-24 09:35:23 +0000
commit5dccf065dbff50587d2c235eeac28ed98e87d53e (patch)
treee59e09fa4f4628b03cbfe169a0a0d27dc8b17453 /app/models/info_request.rb
parent788ddd480c7c131a5c04d0923ccb354a545c39b1 (diff)
Send email to remind people to classify their response.
Diffstat (limited to 'app/models/info_request.rb')
-rw-r--r--app/models/info_request.rb18
1 files changed, 14 insertions, 4 deletions
diff --git a/app/models/info_request.rb b/app/models/info_request.rb
index 3c0e97107..ef6f4bc4d 100644
--- a/app/models/info_request.rb
+++ b/app/models/info_request.rb
@@ -22,7 +22,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.71 2008-03-21 14:45:38 francis Exp $
+# $Id: info_request.rb,v 1.72 2008-03-24 09:35:23 francis Exp $
require 'digest/sha1'
@@ -356,17 +356,27 @@ public
end
# The last response is the default one people might want to reply to
- def get_last_response
+ def get_last_response_event_id
events = self.info_request_events.find(:all, :order => "created_at")
events.reverse.each do |e|
if e.event_type == 'response'
- id = e.params[:incoming_message_id].to_i
- return IncomingMessage.find(id)
+ return e.id
end
end
return nil
end
+ # The last response is the default one people might want to reply to
+ def get_last_response
+ event_id = self.get_last_response_event_id
+ if event_id.nil?
+ return nil
+ end
+ e = self.info_request_events.find(event_id)
+ incoming_message_id = e.params[:incoming_message_id].to_i
+ return IncomingMessage.find(incoming_message_id)
+ end
+
# The last outgoing message
def get_last_outgoing_event
events = self.info_request_events.find(:all, :order => "created_at")