aboutsummaryrefslogtreecommitdiffstats
path: root/app/models/info_request.rb
diff options
context:
space:
mode:
authorfrancis <francis>2008-08-29 09:44:31 +0000
committerfrancis <francis>2008-08-29 09:44:31 +0000
commit1b8a047455d256c2a609169b76d4f6ae91b91c61 (patch)
treefe17d900c12c4a3496c32ff444ac9344e8651604 /app/models/info_request.rb
parentf42ffcf27a0e8f893534a3f5a4e2e2cdc3603fcc (diff)
Comment alerts.
Diffstat (limited to 'app/models/info_request.rb')
-rw-r--r--app/models/info_request.rb34
1 files changed, 20 insertions, 14 deletions
diff --git a/app/models/info_request.rb b/app/models/info_request.rb
index 8e303eed2..5cc4afabf 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.131 2008-08-26 16:03:36 francis Exp $
+# $Id: info_request.rb,v 1.132 2008-08-29 09:44:31 francis Exp $
require 'digest/sha1'
require File.join(File.dirname(__FILE__),'../../vendor/plugins/acts_as_xapian/lib/acts_as_xapian')
@@ -496,6 +496,16 @@ public
info_request_event.save!
end
+ # The last comment made, for alerts
+ def get_last_comment_event
+ for e in self.info_request_events.reverse
+ if e.event_type == 'comment'
+ return e
+ end
+ end
+ return nil
+ end
+
# The last response is the default one people might want to reply to
def get_last_response_event_id
for e in self.info_request_events.reverse
@@ -505,25 +515,21 @@ public
end
return nil
end
-
- # The last response is the default one people might want to reply to
def get_last_response_event
- info_request_event_id = get_last_response_event_id
- if info_request_event_id.nil?
- return nil
- else
- return InfoRequestEvent.find(info_request_event_id)
+ for e in self.info_request_events.reverse
+ if e.event_type == 'response'
+ return e
+ 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?
+ last_response_event = self.get_last_response_event
+ if last_response_event.nil?
return nil
+ else
+ return last_response_event.incoming_message
end
- e = self.info_request_events.find(event_id)
- return e.incoming_message
end
# The last outgoing message