aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/helpers/public_body_helper.rb26
-rw-r--r--app/models/public_body.rb29
-rw-r--r--app/views/public_body/show.html.erb2
3 files changed, 27 insertions, 30 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
diff --git a/app/models/public_body.rb b/app/models/public_body.rb
index c023b436c..0e90a3c16 100644
--- a/app/models/public_body.rb
+++ b/app/models/public_body.rb
@@ -345,35 +345,6 @@ class PublicBody < ActiveRecord::Base
end
end
-
- # Use tags to describe what type of thing this is
- def type_of_authority(html = false)
- types = 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
-
- if html
- # TODO: this should call proper route helpers, but is in model sigh
- desc = '<a href="/body/list/' + tag.name + '">' + desc + '</a>'
- end
-
- desc
- end
- end
-
- types.compact!
-
- if types.any?
- types.to_sentence(:last_word_connector => ' and ').html_safe
- else
- _("A public authority")
- end
- end
-
# Guess home page from the request email, or use explicit override, or nil
# if not known.
def calculated_home_page
diff --git a/app/views/public_body/show.html.erb b/app/views/public_body/show.html.erb
index 5c11c9428..016c2460d 100644
--- a/app/views/public_body/show.html.erb
+++ b/app/views/public_body/show.html.erb
@@ -13,7 +13,7 @@
<div class="authority__header">
<h1><%=h(@public_body.name)%></h1>
<p class="authority__header__subtitle">
- <%=@public_body.type_of_authority(true)%><% if not @public_body.short_name.empty? %>,
+ <%= type_of_authority(@public_body) %><% if not @public_body.short_name.empty? %>,
<%= _('also called {{public_body_short_name}}', :public_body_short_name => h(@public_body.short_name))%><% end %>
<% if !@user.nil? && @user.admin_page_links? %>
(<%= link_to _("admin"), admin_body_path(@public_body) %>)