aboutsummaryrefslogtreecommitdiffstats
path: root/app/helpers
diff options
context:
space:
mode:
Diffstat (limited to 'app/helpers')
-rw-r--r--app/helpers/admin_helper.rb6
-rwxr-xr-xapp/helpers/link_to_helper.rb4
-rw-r--r--app/helpers/public_body_helper.rb61
3 files changed, 66 insertions, 5 deletions
diff --git a/app/helpers/admin_helper.rb b/app/helpers/admin_helper.rb
index 151e53758..d13fea79b 100644
--- a/app/helpers/admin_helper.rb
+++ b/app/helpers/admin_helper.rb
@@ -21,17 +21,17 @@ module AdminHelper
def request_both_links(info_request)
link_to(eye, request_path(info_request), :title => "view request on public website") + " " +
- link_to(info_request.title, admin_request_show_path(info_request), :title => "view full details")
+ link_to(info_request.title, admin_request_path(info_request), :title => "view full details")
end
def public_body_both_links(public_body)
link_to(eye, public_body_path(public_body), :title => "view authority on public website") + " " +
- link_to(h(public_body.name), admin_body_show_path(public_body), :title => "view full details")
+ link_to(h(public_body.name), admin_body_path(public_body), :title => "view full details")
end
def user_both_links(user)
link_to(eye, user_path(user), :title => "view user's page on public website") + " " +
- link_to(h(user.name), admin_user_show_path(user), :title => "view full details")
+ link_to(h(user.name), admin_user_path(user), :title => "view full details")
end
def comment_visibility(comment)
diff --git a/app/helpers/link_to_helper.rb b/app/helpers/link_to_helper.rb
index 3709469cf..44d6c6f5f 100755
--- a/app/helpers/link_to_helper.rb
+++ b/app/helpers/link_to_helper.rb
@@ -116,7 +116,7 @@ module LinkToHelper
if request.is_external?
external_text || (request.external_user_name || _("Anonymous user")) + " (external)"
else
- link_to(internal_text || request.user.name, admin_user_show_url(request.user))
+ link_to(internal_text || request.user.name, admin_user_url(request.user))
end
end
@@ -178,7 +178,7 @@ module LinkToHelper
end
def user_admin_link(user, name="admin", cls=nil)
- link_to name, admin_user_show_url(user), :class => cls
+ link_to name, admin_user_url(user), :class => cls
end
# Tracks. feed can be 'track' or 'feed'
diff --git a/app/helpers/public_body_helper.rb b/app/helpers/public_body_helper.rb
new file mode 100644
index 000000000..332e93284
--- /dev/null
+++ b/app/helpers/public_body_helper.rb
@@ -0,0 +1,61 @@
+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 authority'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
+
+ # Use tags to describe what type of authority a PublicBody is.
+ #
+ # public_body - Instance of a PublicBody
+ #
+ # Returns a string
+ def type_of_authority(public_body)
+ types = public_body.tags.each_with_index.map do |tag, index|
+ if PublicBodyCategory.get().by_tag().include?(tag.name)
+ desc = PublicBodyCategory.get().singular_by_tag()[tag.name]
+
+ if index.zero?
+ desc = desc.sub(/\S/) { |m| Unicode.upcase(m) }
+ end
+ link_to(desc, list_public_bodies_path(tag.name))
+ end
+ end
+
+ types.compact!
+
+ if types.any?
+ types.to_sentence(:last_word_connector => ' and ').html_safe
+ else
+ _("A public authority")
+ end
+ end
+
+end