diff options
author | Gareth Rees <gareth@mysociety.org> | 2015-02-20 12:11:22 +0000 |
---|---|---|
committer | Gareth Rees <gareth@mysociety.org> | 2015-02-20 12:11:22 +0000 |
commit | 9ea4546e07cb891be6fdf0012efb9f78c2005918 (patch) | |
tree | f4505a553844c7a4659258397e5461f56f7fc8c4 /app/helpers | |
parent | 882d812190259d44a470198ee6846cbbcfbbd1c3 (diff) | |
parent | 8648236927ae030452d2ff2e18e6ce37b8c2f955 (diff) |
Merge branch 'add-make-request-button-to-search-results' into rails-3-develop
Diffstat (limited to 'app/helpers')
-rw-r--r-- | app/helpers/public_body_helper.rb | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/app/helpers/public_body_helper.rb b/app/helpers/public_body_helper.rb new file mode 100644 index 000000000..d8a5d57b5 --- /dev/null +++ b/app/helpers/public_body_helper.rb @@ -0,0 +1,35 @@ +module PublicBodyHelper + + # Public: The reasons a request can't be made to a PublicBody + # The returned reasons are ordered by priority. For example, if the body no + # longer exists there is no reason to ask for its contact details if we don't + # have an email for it. + # + # public_body - Instance of a PublicBody + # + # Returns an Array + def public_body_not_requestable_reasons(public_body) + reasons = [] + + if public_body.defunct? + reasons.push _('This authority no longer exists, so you cannot make a request to it.') + end + + if public_body.not_apply? + reasons.push _('Freedom of Information law does not apply to this authority, so you cannot make a request to it.') + end + + unless public_body.has_request_email? + # Make the authority appear requestable to encourage users to help find + # the authroty's email address + msg = link_to _("Make a request to this authority"), + new_request_to_body_path(:url_name => public_body.url_name), + :class => "link_button_green" + + reasons.push(msg) + end + + reasons.compact + end + +end |