aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorFrancis Irving <francis@mysociety.org>2010-08-04 00:37:41 +0100
committerFrancis Irving <francis@mysociety.org>2010-08-04 00:37:41 +0100
commit47e9c70b6d70c7ffbbb5232b56c0463c68600c3f (patch)
tree7487e4753e6abc6075bce992a9d455d4d682087c /app
parentcbb1023f86be15a3ce7efc9b0e54e1725c9561cf (diff)
Allow multiple keys the same
Diffstat (limited to 'app')
-rw-r--r--app/models/public_body.rb16
-rw-r--r--app/views/public_body/show.rhtml10
2 files changed, 19 insertions, 7 deletions
diff --git a/app/models/public_body.rb b/app/models/public_body.rb
index e0d02a5b6..ae1a38723 100644
--- a/app/models/public_body.rb
+++ b/app/models/public_body.rb
@@ -216,13 +216,23 @@ class PublicBody < ActiveRecord::Base
end
return false
end
- def get_tag_value(tag)
+ class TagNotFound < StandardError
+ end
+ def get_tag_values(tag)
+ found = false
+ results = []
for public_body_tag in self.public_body_tags
if public_body_tag.name == tag
- return public_body_tag.value
+ found = true
+ if !public_body_tag.value.nil?
+ results << public_body_tag.value
+ end
end
end
- return false
+ if !found
+ raise TagNotFound
+ end
+ return results
end
def add_tag_if_not_already_present(tag)
self.tag_string = self.tag_string + " " + tag
diff --git a/app/views/public_body/show.rhtml b/app/views/public_body/show.rhtml
index e2ea625cd..e6fe61a0a 100644
--- a/app/views/public_body/show.rhtml
+++ b/app/views/public_body/show.rhtml
@@ -11,10 +11,12 @@
<%= link_to "Publication scheme", @public_body.publication_scheme %><br>
<% end %>
<% if @public_body.has_tag?("charity") %>
- <% if @public_body.get_tag_value("charity").match(/^SC/) %>
- <%= link_to "Charity registration", "http://www.oscr.org.uk/CharityIndexDetails.aspx?id=" + @public_body.get_tag_value("charity") %><br>
- <% else %>
- <%= link_to "Charity registration", "http://www.charity-commission.gov.uk/SHOWCHARITY/RegisterOfCharities/CharityFramework.aspx?RegisteredCharityNumber=" + @public_body.get_tag_value("charity") %><br>
+ <% for tag_value in @public_body.get_tag_values("charity") %>
+ <% if tag_value.match(/^SC/) %>
+ <%= link_to "Charity registration", "http://www.oscr.org.uk/CharityIndexDetails.aspx?id=" + tag_value %><br>
+ <% else %>
+ <%= link_to "Charity registration", "http://www.charity-commission.gov.uk/SHOWCHARITY/RegisterOfCharities/CharityFramework.aspx?RegisteredCharityNumber=" + tag_value %><br>
+ <% end %>
<% end %>
<% end %>
<%= link_to "View FOI email address", view_public_body_email_url(@public_body.url_name) %><br>