aboutsummaryrefslogtreecommitdiffstats
path: root/app/models/public_body.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/public_body.rb')
-rw-r--r--app/models/public_body.rb12
1 files changed, 10 insertions, 2 deletions
diff --git a/app/models/public_body.rb b/app/models/public_body.rb
index d7c3a3de6..3d2b180b8 100644
--- a/app/models/public_body.rb
+++ b/app/models/public_body.rb
@@ -48,7 +48,11 @@ class PublicBody < ActiveRecord::Base
# 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)
+ @localer = I18n.locale.to_s
+ PublicBody.with_locale(@locale) do
+ found = PublicBody.find(:all,
+ :conditions => ["public_body_translations.url_name='#{name}' AND public_body_translations.locale = '#{@localer}'"],
+ :joins => :translations)
return found.first if found.size == 1
# Shouldn't we just make url_name unique?
raise "Two bodies with the same URL name: #{name}" if found.size > 1
@@ -64,7 +68,10 @@ class PublicBody < ActiveRecord::Base
# does acts_as_versioned provide a method that returns the current version?
return PublicBody.find(old.first)
end
+ end
+
+ load "public_body_categories_#{I18n.locale.to_s}.rb"
# Set the first letter, which is used for faster queries
before_save(:set_first_letter)
@@ -272,6 +279,7 @@ class PublicBody < ActiveRecord::Base
:request_email => MySociety::Config.get("CONTACT_EMAIL", 'contact@localhost'),
:home_page => "",
:notes => "",
+ :publication_scheme => "",
:last_edit_editor => "internal_admin",
:last_edit_comment => "Made by PublicBody.internal_admin_body"
)
@@ -337,7 +345,7 @@ class PublicBody < ActiveRecord::Base
else
# New public body
notes.push "line " + line.to_s + ": new authority '" + name + "' with email " + email
- public_body = PublicBody.new(:name => name, :request_email => email, :short_name => "", :home_page => "", :notes => "", :last_edit_editor => editor, :last_edit_comment => 'Created from spreadsheet')
+ public_body = PublicBody.new(:name => name, :request_email => email, :short_name => "", :home_page => "", :publication_scheme => "", :notes => "", :last_edit_editor => editor, :last_edit_comment => 'Created from spreadsheet')
public_body.tag_string = tag
public_body.save!
end