diff options
Diffstat (limited to 'app/models/public_body.rb')
-rw-r--r-- | app/models/public_body.rb | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/app/models/public_body.rb b/app/models/public_body.rb index 961fa3cbb..54af547bd 100644 --- a/app/models/public_body.rb +++ b/app/models/public_body.rb @@ -240,7 +240,7 @@ class PublicBody < ActiveRecord::Base # 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 + self.name.nil? ? "" : self.name else self.short_name end @@ -282,19 +282,11 @@ class PublicBody < ActiveRecord::Base # Guess home page from the request email, or use explicit override, or nil # if not known. def calculated_home_page - # manual override for ones we calculate wrongly - if self.home_page != '' - return self.home_page + if home_page && !home_page.empty? + home_page[URI::regexp(%w(http https))] ? home_page : "http://#{home_page}" + elsif request_email_domain + "http://www.#{request_email_domain}" end - - # extract the domain name from the FOI request email - url = self.request_email_domain - if url.nil? - return nil - end - - # add standard URL prefix - return "http://www." + url end # Are all requests to this body under the Environmental Information Regulations? @@ -527,7 +519,7 @@ class PublicBody < ActiveRecord::Base end def has_notes? - return self.notes != "" + return !self.notes.nil? && self.notes != "" end def notes_as_html self.notes @@ -555,6 +547,11 @@ class PublicBody < ActiveRecord::Base } end + after_save(:purge_in_cache) + def purge_in_cache + self.info_requests.each {|x| x.purge_in_cache} + end + end |