aboutsummaryrefslogtreecommitdiffstats
path: root/app/models
diff options
context:
space:
mode:
authorGareth Rees <gareth@mysociety.org>2015-02-20 12:11:22 +0000
committerGareth Rees <gareth@mysociety.org>2015-02-20 12:11:22 +0000
commit9ea4546e07cb891be6fdf0012efb9f78c2005918 (patch)
treef4505a553844c7a4659258397e5461f56f7fc8c4 /app/models
parent882d812190259d44a470198ee6846cbbcfbbd1c3 (diff)
parent8648236927ae030452d2ff2e18e6ce37b8c2f955 (diff)
Merge branch 'add-make-request-button-to-search-results' into rails-3-develop
Diffstat (limited to 'app/models')
-rw-r--r--app/models/public_body.rb33
1 files changed, 16 insertions, 17 deletions
diff --git a/app/models/public_body.rb b/app/models/public_body.rb
index b8163b07d..5e5b35c5b 100644
--- a/app/models/public_body.rb
+++ b/app/models/public_body.rb
@@ -235,39 +235,38 @@ class PublicBody < ActiveRecord::Base
return self.has_tag?('defunct')
end
- # Can an FOI (etc.) request be made to this body, and if not why not?
+ # Can an FOI (etc.) request be made to this body?
def is_requestable?
- if self.defunct?
- return false
- end
- if self.not_apply?
- return false
- end
- if self.request_email.nil?
- return false
- end
- return !self.request_email.empty? && self.request_email != 'blank'
+ has_request_email? && !defunct? && !not_apply?
end
+
# Strict superset of is_requestable?
def is_followupable?
- if self.request_email.nil?
- return false
- end
- return !self.request_email.empty? && self.request_email != 'blank'
+ has_request_email?
+ end
+
+ def has_request_email?
+ !request_email.blank? && request_email != 'blank'
end
+
# Also used as not_followable_reason
def not_requestable_reason
if self.defunct?
return 'defunct'
elsif self.not_apply?
return 'not_apply'
- elsif self.request_email.nil? or self.request_email.empty? or self.request_email == 'blank'
+ elsif !has_request_email?
return 'bad_contact'
else
- raise "requestable_failure_reason called with type that has no reason"
+ raise "not_requestable_reason called with type that has no reason"
end
end
+ def special_not_requestable_reason?
+ self.defunct? || self.not_apply?
+ end
+
+
class Version
def last_edit_comment_for_html_display