diff options
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/incoming_message.rb | 6 | ||||
-rw-r--r-- | app/models/public_body.rb | 19 |
2 files changed, 20 insertions, 5 deletions
diff --git a/app/models/incoming_message.rb b/app/models/incoming_message.rb index 48d5c8e68..9a686ac5d 100644 --- a/app/models/incoming_message.rb +++ b/app/models/incoming_message.rb @@ -18,7 +18,7 @@ # Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ # -# $Id: incoming_message.rb,v 1.114 2008-06-23 22:12:15 francis Exp $ +# $Id: incoming_message.rb,v 1.115 2008-06-23 23:20:45 francis Exp $ # TODO # Move some of the (e.g. quoting) functions here into rblib, as they feel @@ -167,7 +167,7 @@ class IncomingMessage < ActiveRecord::Base # XXX can later display some of these special emails as actual emails, # if they are public anyway. For now just be precautionary and only # put in descriptions of them in square brackets. - if not self.info_request.public_body.request_email.empty? + if info_request.public_body.is_requestable? text = text.gsub(self.info_request.public_body.request_email, "[" + self.info_request.public_body.short_or_long_name + " request email]") end text = text.gsub(self.info_request.incoming_email, "[FOI #" + self.info_request.id.to_s + " email]") @@ -177,7 +177,7 @@ class IncomingMessage < ActiveRecord::Base # Replaces emails we know about in (possibly binary data) with equal length alternative ones. def binary_mask_special_emails(text) - if not self.info_request.public_body.request_email.empty? + if info_request.public_body.is_requestable? text = IncomingMessage.mask_string_multicharset(text, self.info_request.public_body.request_email) end text = IncomingMessage.mask_string_multicharset(text, self.info_request.incoming_email) diff --git a/app/models/public_body.rb b/app/models/public_body.rb index 8a5d369b2..3303dca20 100644 --- a/app/models/public_body.rb +++ b/app/models/public_body.rb @@ -21,7 +21,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.76 2008-06-23 22:03:25 francis Exp $ +# $Id: public_body.rb,v 1.77 2008-06-23 23:20:45 francis Exp $ require 'csv' require 'set' @@ -71,13 +71,28 @@ class PublicBody < ActiveRecord::Base def validate # Request_email can be blank, meaning we don't have details - if self.request_email != "" + if self.is_requestable? unless MySociety::Validate.is_valid_email(self.request_email) errors.add(:request_email, "doesn't look like a valid email address") end end end + # Can an FOI (etc.) request be made to this body, and if not why not? + def is_requestable? + not self.request_email.empty? and self.request_email != 'blank' and self.request_email != 'not_apply' + end + def not_requestable_reason + if self.request_email.empty? or self.request_email == 'blank' + return 'bad_contact' + elsif self.request_email == 'not_apply' + return 'not_apply' + else + raise "requestable_failure_reason called with type that has no reason" + end + end + + acts_as_versioned self.non_versioned_columns << 'created_at' << 'updated_at' class Version |