aboutsummaryrefslogtreecommitdiffstats
path: root/app/helpers/public_body_helper.rb
diff options
context:
space:
mode:
authorLouise Crow <louise.crow@gmail.com>2015-02-26 16:27:04 +0000
committerLouise Crow <louise.crow@gmail.com>2015-03-05 13:38:45 +0000
commit0947b1445ce4e6ac73e2a7a1536ab4aac775f6a6 (patch)
treed6d4b92d724281ef988eb646e18790c98a16df7b /app/helpers/public_body_helper.rb
parent1129fe5593cba72309399d4b16e0d07d3291b040 (diff)
Use routing helper to generate localised urls.
Diffstat (limited to 'app/helpers/public_body_helper.rb')
-rw-r--r--app/helpers/public_body_helper.rb26
1 files changed, 26 insertions, 0 deletions
diff --git a/app/helpers/public_body_helper.rb b/app/helpers/public_body_helper.rb
index d8a5d57b5..cb4b71cb3 100644
--- a/app/helpers/public_body_helper.rb
+++ b/app/helpers/public_body_helper.rb
@@ -32,4 +32,30 @@ module PublicBodyHelper
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