aboutsummaryrefslogtreecommitdiffstats
path: root/app/helpers
diff options
context:
space:
mode:
authorLouise Crow <louise.crow@gmail.com>2015-03-05 13:41:50 +0000
committerLouise Crow <louise.crow@gmail.com>2015-03-05 13:41:50 +0000
commit7bc05735fd6b138d09e92be08979c86525b1b0bd (patch)
tree3317d7ae235673b322eacd3d75642f5daa62791f /app/helpers
parent13408b4569f8c164e275cb594920813ec8210aec (diff)
parent0947b1445ce4e6ac73e2a7a1536ab4aac775f6a6 (diff)
Merge branch '59-localised-authority-links' into rails-3-develop
Conflicts: app/views/public_body/show.html.erb
Diffstat (limited to 'app/helpers')
-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 4a71f89ab..332e93284 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