diff options
Diffstat (limited to 'app/models/info_request_event.rb')
-rw-r--r-- | app/models/info_request_event.rb | 40 |
1 files changed, 22 insertions, 18 deletions
diff --git a/app/models/info_request_event.rb b/app/models/info_request_event.rb index 09eba31ab..0967e3940 100644 --- a/app/models/info_request_event.rb +++ b/app/models/info_request_event.rb @@ -20,7 +20,7 @@ # models/info_request_event.rb: # # Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. -# Email: francis@mysociety.org; WWW: http://www.mysociety.org/ +# Email: hello@mysociety.org; WWW: http://www.mysociety.org/ class InfoRequestEvent < ActiveRecord::Base belongs_to :info_request @@ -77,17 +77,18 @@ class InfoRequestEvent < ActiveRecord::Base end def user_can_view?(user) - if !self.info_request.user_can_view?(user) + unless info_request.user_can_view?(user) raise "internal error, called user_can_view? on event when there is not permission to view entire request" end - if self.prominence == 'hidden' - return User.view_hidden_requests?(user) - end - if self.prominence == 'requester_only' - return self.info_request.is_owning_user?(user) + case prominence + when 'hidden' + User.view_hidden_requests?(user) + when 'requester_only' + info_request.is_owning_user?(user) + else + true end - return true end @@ -363,16 +364,19 @@ class InfoRequestEvent < ActiveRecord::Base end def is_sent_sort? - if [ 'sent', 'resent'].include?(self.event_type) - return true - end - return false + ['sent', 'resent'].include?(event_type) end + def is_followup_sort? - if [ 'followup_sent', 'followup_resent'].include?(self.event_type) - return true - end - return false + ['followup_sent', 'followup_resent'].include?(event_type) + end + + def outgoing? + ['sent', 'followup_sent'].include?(event_type) + end + + def response? + event_type == 'response' end def same_email_as_previous_send? @@ -401,7 +405,7 @@ class InfoRequestEvent < ActiveRecord::Base :comment_id => self.comment_id, # XXX would be nice to add links here, but alas the - # code to make them is in views only. See views/request/details.rhtml + # code to make them is in views only. See views/request/details.html.erb # perhaps can call with @template somehow } @@ -416,7 +420,7 @@ class InfoRequestEvent < ActiveRecord::Base if deep ret[:info_request] = self.info_request.json_for_api(false) ret[:public_body] = self.info_request.public_body.json_for_api - ret[:user] = self.info_request.user.json_for_api + ret[:user] = self.info_request.user_json_for_api end return ret |