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.rb40
1 files changed, 8 insertions, 32 deletions
diff --git a/app/models/public_body.rb b/app/models/public_body.rb
index b648ded0f..33be49052 100644
--- a/app/models/public_body.rb
+++ b/app/models/public_body.rb
@@ -55,11 +55,11 @@ class PublicBody < ActiveRecord::Base
has_tag_string
before_save :set_api_key,
- :set_default_publication_scheme,
- :set_first_letter
+ :set_default_publication_scheme
after_save :purge_in_cache
after_update :reindex_requested_from
+
# Every public body except for the internal admin one is visible
scope :visible, lambda {
{
@@ -70,6 +70,11 @@ class PublicBody < ActiveRecord::Base
translates :name, :short_name, :request_email, :url_name, :notes, :first_letter, :publication_scheme
accepts_nested_attributes_for :translations, :reject_if => :empty_translation_in_params?
+ include PublicBodyDerivedFields
+ class Translation
+ include PublicBodyDerivedFields
+ end
+
# Default fields available for importing from CSV, in the format
# [field_name, 'short description of field (basic html allowed)']
cattr_accessor :csv_import_fields do
@@ -207,10 +212,7 @@ class PublicBody < ActiveRecord::Base
return PublicBody.find(old.first)
end
- # Set the first letter, which is used for faster queries
- def set_first_letter
- PublicBody.set_first_letter(self)
- end
+
# If tagged "not_apply", then FOI/EIR no longer applies to authority at all
def not_apply?
@@ -305,32 +307,6 @@ class PublicBody < ActiveRecord::Base
end
end
- # When name or short name is changed, also change the url name
- def short_name=(short_name)
- globalize.write(Globalize.locale, :short_name, short_name)
- self[:short_name] = short_name
- self.update_url_name
- end
-
- def name=(name)
- globalize.write(Globalize.locale, :name, name)
- self[:name] = name
- self.update_url_name
- end
-
- def update_url_name
- self.url_name = MySociety::Format.simplify_url_part(self.short_or_long_name, 'body')
- end
-
- # Return the short name if present, or else long name
- def short_or_long_name
- if self.short_name.nil? || self.short_name.empty? # 'nil' can happen during construction
- self.name.nil? ? "" : self.name
- else
- self.short_name
- end
- end
-
# Guess home page from the request email, or use explicit override, or nil
# if not known.
def calculated_home_page