aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/controllers/public_body_controller.rb6
-rw-r--r--app/models/public_body.rb85
-rw-r--r--app/views/admin_public_body/_form.rhtml2
-rw-r--r--app/views/admin_public_body/import_csv.rhtml2
-rw-r--r--app/views/public_body/list.rhtml2
5 files changed, 9 insertions, 88 deletions
diff --git a/app/controllers/public_body_controller.rb b/app/controllers/public_body_controller.rb
index 0ec9f1a32..1ca82e463 100644
--- a/app/controllers/public_body_controller.rb
+++ b/app/controllers/public_body_controller.rb
@@ -4,7 +4,7 @@
# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved.
# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
#
-# $Id: public_body_controller.rb,v 1.7 2009-09-10 14:59:35 francis Exp $
+# $Id: public_body_controller.rb,v 1.8 2009-09-14 13:27:00 francis Exp $
class PublicBodyController < ApplicationController
# XXX tidy this up with better error messages, and a more standard infrastructure for the redirect to canonical URL
@@ -68,7 +68,7 @@ class PublicBodyController < ApplicationController
@tag = "all"
conditions = []
elsif @tag == 'other'
- category_list = PublicBody::CATEGORIES.map{|c| "'"+c+"'"}.join(",")
+ category_list = PublicBodyCategories::CATEGORIES.map{|c| "'"+c+"'"}.join(",")
conditions = ['(select count(*) from public_body_tags where public_body_tags.public_body_id = public_bodies.id
and public_body_tags.name in (' + category_list + ')) = 0']
elsif @tag.size == 1
@@ -85,7 +85,7 @@ class PublicBodyController < ApplicationController
if @tag.size == 1
@description = "beginning with '" + @tag + "'"
else
- @description = PublicBody::CATEGORIES_BY_TAG[@tag]
+ @description = PublicBodyCategories::CATEGORIES_BY_TAG[@tag]
if @description.nil?
@description = @tag
end
diff --git a/app/models/public_body.rb b/app/models/public_body.rb
index 0fe451c14..4ff36ea3f 100644
--- a/app/models/public_body.rb
+++ b/app/models/public_body.rb
@@ -26,7 +26,7 @@
# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved.
# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
#
-# $Id: public_body.rb,v 1.157 2009-09-14 09:16:25 francis Exp $
+# $Id: public_body.rb,v 1.158 2009-09-14 13:27:01 francis Exp $
require 'csv'
require 'set'
@@ -44,85 +44,6 @@ class PublicBody < ActiveRecord::Base
has_many :public_body_tags
has_many :track_things, :order => 'created_at desc'
- CATEGORIES_WITH_HEADINGS = [
- "Miscellaneous",
- [ "other", "Miscellaneous", "miscellaneous" ],
- "Central government",
- [ "department", "Ministerial departments", "a ministerial department" ],
- [ "non_ministerial_department", "Non-ministerial departments", "a non-ministerial department" ],
- [ "executive_agency", "Executive agencies", "an executive agency" ],
- [ "government_office", "Government offices for the regions", "a government office for the regions" ],
- [ "advisory_committee", "Advisory committees", "an advisory committee" ],
- [ "awc", "Agricultural wages committees", "an agriculatural wages committee" ],
- [ "adhac", "Agricultural dwelling house advisory committees", "an agriculatural dwelling house advisory committee" ],
- [ "newdeal", "New Deal for Communities partnership", "a New Deal for Communities partnership" ],
- "Local and regional",
- [ "local_council", "Local councils", "a local council" ],
- [ "parish_council", "Town and Parish councils", "a town or parish council"],
- [ "housing_association", "Housing associations", "a housing association"],
- [ "almo", "Housing ALMOs", "a housing ALMO"],
- [ "municipal_bank", "Municipal bank", "a municipal bank"],
- [ "nsbody", "North/south bodies", "a north/south body"],
- [ "pbo", "Professional buying organisations", "a professional buying organisation"],
- [ "regional_assembly", "Regional assemblies", "a regional assembly"],
- [ "rda", "Regional development agencies", "a regional development agency" ],
- "Education",
- [ "university", "Universities", "a university" ],
- [ "university_college", "University colleges", "a university college" ],
- [ "cambridge_college", "Cambridge colleges", "a Cambridge college" ],
- [ "durham_college", "Durham colleges", "a Durham college" ],
- [ "oxford_college", "Oxford colleges", "an Oxford college or permanent private hall" ],
- [ "york_college", "York colleges", "a college of the University of York" ],
- [ "university_owned_company", "University owned companies", "a university owned company" ],
- [ "hei", "Higher education institutions", "a higher educational institution" ],
- [ "fei", "Further education institutions", "a further educational institution" ],
- [ "school", "Schools", "a school" ],
- [ "research_council", "Research councils", "a research council" ],
- [ "lib_board", "Education and library boards", "an education and library board" ],
- "Environment",
- [ "npa", "National park authorities", "a national park authority" ],
- [ "rpa", "Regional park authorities", "a regional park authority" ],
- [ "sea_fishery_committee", "Sea fisheries committees", "a sea fisheries committee" ],
- [ "watercompanies", "Water companies", "a water company" ],
- [ "idb", "Internal drainage boards", "an internal drainage board" ],
- [ "rfdc", "Regional flood defence committees", "a regional flood defence committee" ],
- [ "wda", "Waste disposal authorities", "a waste disposal authority" ],
- [ "zoo", "Zoos", "a zoo" ],
- "Health",
- [ "nhstrust", "NHS trusts", "an NHS trust" ],
- [ "pct", "Primary care trusts", "a primary care trust" ],
- [ "nhswales", "NHS in Wales", "part of the NHS in Wales" ],
- [ "nhsni", "NHS in Northern Ireland", "part of the NHS in Northern Ireland" ],
- [ "hscr", "Health / social care", "Relating to health / social care" ],
- [ "pha", "Port health authorities", "a port health authority"],
- [ "sha", "Strategic health authorities", "a strategic health authority" ],
- [ "specialha", "Special health authorities", "a special health authority" ],
- "Media and culture",
- [ "media", "Media", "a media organisation" ],
- [ "rcc", "Cultural consortia", "a cultural consortium"],
- [ "museum", "Museums and galleries", "a museum or gallery" ],
- "Military and security services",
- [ "military_college", "Military colleges", "a military college" ],
- [ "security_services", "Security services", "a security services body" ],
- "Emergency services and the courts",
- [ "police", "Police forces", "a police force" ],
- [ "police_authority", "Police authorities", "a police authority" ],
- [ "dpp", "District policing partnerships", "a district policing partnership" ],
- [ "fire_service", "Fire and rescue services", "a fire and rescue service" ],
- [ "prob_board", "Probation boards", "a probation board" ],
- [ "rules_committee", "Rules commitees", "a rules committee" ],
- [ "tribunal", "Tribunals", "a tribunal"],
- "Transport",
- [ "npte", "Passenger transport executives", "a passenger transport executive" ],
- [ "port_authority", "Port authorities", "a port authority" ],
- [ "scp", "Safety Camera Partnerships", "a safety camera partnership" ],
- [ "srp", "Safer Roads Partnership", "a safer roads partnership" ]
- ]
- CATEGORIES_WITH_DESCRIPTION = CATEGORIES_WITH_HEADINGS.select() { |a| a.instance_of?(Array) }
- CATEGORIES = CATEGORIES_WITH_DESCRIPTION.map() { |a| a[0] }
- CATEGORIES_BY_TAG = Hash[*CATEGORIES_WITH_DESCRIPTION.map() { |a| a[0..1] }.flatten]
- CATEGORY_SINGULAR_BY_TAG = Hash[*CATEGORIES_WITH_DESCRIPTION.map() { |a| [a[0],a[2]] }.flatten]
-
# like find_by_url_name but also search historic url_name if none found
def self.find_by_url_name_with_historic(name)
found = PublicBody.find_all_by_url_name(name)
@@ -303,8 +224,8 @@ class PublicBody < ActiveRecord::Base
types = []
first = true
for tag in self.public_body_tags
- if PublicBody::CATEGORIES_BY_TAG.include?(tag.name)
- desc = PublicBody::CATEGORY_SINGULAR_BY_TAG[tag.name]
+ if PublicBodyCategories::CATEGORIES_BY_TAG.include?(tag.name)
+ desc = PublicBodyCategories::CATEGORY_SINGULAR_BY_TAG[tag.name]
if first
# terrible that Ruby/Rails doesn't have an equivalent of ucfirst
# (capitalize shockingly converts later characters to lowercase)
diff --git a/app/views/admin_public_body/_form.rhtml b/app/views/admin_public_body/_form.rhtml
index 97c4d47c9..744d7de64 100644
--- a/app/views/admin_public_body/_form.rhtml
+++ b/app/views/admin_public_body/_form.rhtml
@@ -5,7 +5,7 @@
<div id="tag_help">
<h2>List of tags</h2>
<% first_row = true %>
- <% for row in PublicBody::CATEGORIES_WITH_HEADINGS %>
+ <% for row in PublicBodyCategories::CATEGORIES_WITH_HEADINGS %>
<% if row.instance_of?(Array) %>
<% if row[0] != 'other' %>
<strong><%= row[0] %></strong>=<%= row[1] %>
diff --git a/app/views/admin_public_body/import_csv.rhtml b/app/views/admin_public_body/import_csv.rhtml
index a3249e284..3ca1f4d59 100644
--- a/app/views/admin_public_body/import_csv.rhtml
+++ b/app/views/admin_public_body/import_csv.rhtml
@@ -13,7 +13,7 @@
<% form_tag 'import_csv', :multipart => true do %>
<p>
<label for="tag">Tag to add entries to (maybe you want:
- <% for category, description in PublicBody::CATEGORIES_BY_TAG %>
+ <% for category, description in PublicBodyCategories::CATEGORIES_BY_TAG %>
<% if category != "other" %>
<strong><%= category %></strong>=<%= description %>;
<% end %>
diff --git a/app/views/public_body/list.rhtml b/app/views/public_body/list.rhtml
index 18314f815..9b03e65d0 100644
--- a/app/views/public_body/list.rhtml
+++ b/app/views/public_body/list.rhtml
@@ -8,7 +8,7 @@
</li></ul>
<% first_row = true %>
-<% for row in PublicBody::CATEGORIES_WITH_HEADINGS %>
+<% for row in PublicBodyCategories::CATEGORIES_WITH_HEADINGS %>
<% if row.instance_of?(Array) %>
<li>
<%= link_to_unless (@tag == row[0]), row[1], list_public_bodies_url(:tag => row[0]) %>