aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/controllers/public_body_controller.rb4
-rw-r--r--app/models/public_body.rb4
-rw-r--r--app/views/admin_public_body/_tag_help.html.erb2
-rw-r--r--app/views/admin_public_body/import_csv.html.erb2
-rw-r--r--app/views/public_body/list.html.erb2
-rw-r--r--config/initializers/alaveteli.rb5
-rw-r--r--lib/public_body_categories.rb11
-rw-r--r--spec/models/public_body_category_spec.rb2
8 files changed, 20 insertions, 12 deletions
diff --git a/app/controllers/public_body_controller.rb b/app/controllers/public_body_controller.rb
index d2c84d820..e64644a1b 100644
--- a/app/controllers/public_body_controller.rb
+++ b/app/controllers/public_body_controller.rb
@@ -111,7 +111,7 @@ class PublicBodyController < ApplicationController
if @tag.nil? || @tag == 'all'
@tag = 'all'
elsif @tag == 'other'
- category_list = PublicBodyCategories.get.tags.map{ |c| %Q('#{ c }') }.join(",")
+ category_list = PublicBodyCategory.get.tags.map{ |c| %Q('#{ c }') }.join(",")
where_condition += base_tag_condition + " AND has_tag_string_tags.name in (#{category_list})) = 0"
elsif @tag.scan(/./mu).size == 1
@tag = Unicode.upcase(@tag)
@@ -132,7 +132,7 @@ class PublicBodyController < ApplicationController
elsif @tag.size == 1
@description = _("beginning with ‘{{first_letter}}’", :first_letter => @tag)
else
- category_name = PublicBodyCategories.get.by_tag[@tag]
+ category_name = PublicBodyCategory.get.by_tag[@tag]
if category_name.nil?
@description = _("matching the tag ‘{{tag_name}}’", :tag_name => @tag)
else
diff --git a/app/models/public_body.rb b/app/models/public_body.rb
index 477503a61..f61a3f449 100644
--- a/app/models/public_body.rb
+++ b/app/models/public_body.rb
@@ -335,8 +335,8 @@ class PublicBody < ActiveRecord::Base
types = []
first = true
for tag in self.tags
- if PublicBodyCategories::get().by_tag().include?(tag.name)
- desc = PublicBodyCategories::get().singular_by_tag()[tag.name]
+ if PublicBodyCategory.get().by_tag().include?(tag.name)
+ desc = PublicBodyCategory.get().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/_tag_help.html.erb b/app/views/admin_public_body/_tag_help.html.erb
index b64e65877..5d6990400 100644
--- a/app/views/admin_public_body/_tag_help.html.erb
+++ b/app/views/admin_public_body/_tag_help.html.erb
@@ -1,6 +1,6 @@
<h2>List of tags</h2>
<% first_row = true %>
-<% for row in PublicBodyCategories::get().with_headings() %>
+<% for row in PublicBodyCategory.get().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.html.erb b/app/views/admin_public_body/import_csv.html.erb
index c690f0fc2..4b14226d1 100644
--- a/app/views/admin_public_body/import_csv.html.erb
+++ b/app/views/admin_public_body/import_csv.html.erb
@@ -76,7 +76,7 @@ Another One,another@example.com,Otro organismo,a_tag
<hr>
<p>Standard tags:
- <% for category, description in PublicBodyCategories::get().by_tag() %>
+ <% for category, description in PublicBodyCategory.get().by_tag() %>
<% if category != "other" %>
<strong><%= category %></strong>=<%= description %>;
<% end %>
diff --git a/app/views/public_body/list.html.erb b/app/views/public_body/list.html.erb
index ce24daaf9..0750c7655 100644
--- a/app/views/public_body/list.html.erb
+++ b/app/views/public_body/list.html.erb
@@ -7,7 +7,7 @@
</li>
</ul>
<% first_row = true %>
- <% for row in PublicBodyCategories::get().with_headings() %>
+ <% for row in PublicBodyCategory.get().with_headings() %>
<% if row.instance_of?(Array) %>
<li>
<%= link_to_unless (@tag == row[0]), row[1], list_public_bodies_path(:tag => row[0]) %>
diff --git a/config/initializers/alaveteli.rb b/config/initializers/alaveteli.rb
index 18cce188d..9a151e3e8 100644
--- a/config/initializers/alaveteli.rb
+++ b/config/initializers/alaveteli.rb
@@ -54,6 +54,7 @@ require 'xapian_queries'
require 'date_quarter'
require 'public_body_csv'
require 'category_and_heading_migrator'
+require 'public_body_categories'
AlaveteliLocalization.set_locales(AlaveteliConfiguration::available_locales,
AlaveteliConfiguration::default_locale)
@@ -63,7 +64,3 @@ if Rails.env == 'test' and ActiveRecord::Base.configurations['test']['constraint
require 'no_constraint_disabling'
end
-# Allow the PublicBodyCategory model to be addressed using the same syntax
-# as the old PublicBodyCategories class without needing to rename everything,
-# make sure we're not going to break any themes
-PublicBodyCategories = PublicBodyCategory
diff --git a/lib/public_body_categories.rb b/lib/public_body_categories.rb
new file mode 100644
index 000000000..3528e85b1
--- /dev/null
+++ b/lib/public_body_categories.rb
@@ -0,0 +1,11 @@
+# Allow the PublicBodyCategory model to be addressed using the same syntax
+# as the old PublicBodyCategories class without needing to rename everything,
+# make sure we're not going to break any themes
+class PublicBodyCategories
+
+ def self.method_missing(method, *args, &block)
+ warn 'Use of PublicBodyCategories is deprecated and will be removed in release 0.21. Please use PublicBodyCategory instead.'
+ PublicBodyCategory.send(method, *args, &block)
+ end
+
+end
diff --git a/spec/models/public_body_category_spec.rb b/spec/models/public_body_category_spec.rb
index 189d1654b..2d39a7376 100644
--- a/spec/models/public_body_category_spec.rb
+++ b/spec/models/public_body_category_spec.rb
@@ -15,7 +15,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe PublicBodyCategory do
describe 'when loading the data' do
it 'should use the display_order field to preserve the original data order' do
- PublicBodyCategories.add(:en, [
+ PublicBodyCategory.add(:en, [
"Local and regional",
[ "local_council", "Local councils", "a local council" ],
"Miscellaneous",