diff options
author | Louise Crow <louise.crow@gmail.com> | 2012-08-16 09:39:36 +0100 |
---|---|---|
committer | Louise Crow <louise.crow@gmail.com> | 2012-08-16 09:39:36 +0100 |
commit | 99ada7eea8db32f35a6386362933391b576919b4 (patch) | |
tree | 1fb9a49d981fc03eedc348b435279a2776222e21 /app/models/info_request.rb | |
parent | 841a699e7061c3d2bcec58d4ff8381ab266747cb (diff) |
Add method all_can_view? which can be used to determine whether it is ok to cache the associated objects for an info request in the file cache which will be served up without authentication.
Diffstat (limited to 'app/models/info_request.rb')
-rw-r--r-- | app/models/info_request.rb | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/app/models/info_request.rb b/app/models/info_request.rb index a41d6d2db..7e69a5cda 100644 --- a/app/models/info_request.rb +++ b/app/models/info_request.rb @@ -104,7 +104,7 @@ class InfoRequest < ActiveRecord::Base errors.add(:described_state, "is not a valid state") if !InfoRequest.enumerate_states.include? described_state end - + # The request must either be internal, in which case it has # a foreign key reference to a User object and no external_url or external_user_name, # or else be external in which case it has no user_id but does have an external_url, @@ -120,15 +120,15 @@ class InfoRequest < ActiveRecord::Base errors.add(:external_url, "must be null for an internal request") if !external_url.nil? end end - + def is_external? !external_url.nil? end - + def user_name is_external? ? external_user_name : user.name end - + def user_name_slug if is_external? if external_user_name.nil? @@ -708,10 +708,10 @@ public return self.public_body.is_followupable? end def recipient_name_and_email - return TMail::Address.address_from_name_and_email( - _("{{law_used}} requests at {{public_body}}", - :law_used => self.law_used_short, - :public_body => self.public_body.short_or_long_name), + return TMail::Address.address_from_name_and_email( + _("{{law_used}} requests at {{public_body}}", + :law_used => self.law_used_short, + :public_body => self.public_body.short_or_long_name), self.recipient_email).to_s end @@ -1035,6 +1035,12 @@ public return true end + # Is this request visible to everyone? + def all_can_view? + return true if ['normal', 'backpage'].include?(self.prominence) + return false + end + def indexed_by_search? if self.prominence == 'backpage' || self.prominence == 'hidden' || self.prominence == 'requester_only' return false |