diff options
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/info_request.rb | 56 | ||||
-rw-r--r-- | app/models/public_body.rb | 16 |
2 files changed, 67 insertions, 5 deletions
diff --git a/app/models/info_request.rb b/app/models/info_request.rb index 14cd503ba..cc1aef022 100644 --- a/app/models/info_request.rb +++ b/app/models/info_request.rb @@ -22,7 +22,7 @@ # Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ # -# $Id: info_request.rb,v 1.114 2008-05-21 22:37:33 francis Exp $ +# $Id: info_request.rb,v 1.115 2008-05-27 01:19:45 francis Exp $ require 'digest/sha1' require File.join(File.dirname(__FILE__),'../../vendor/plugins/acts_as_xapian/lib/acts_as_xapian') @@ -59,10 +59,19 @@ class InfoRequest < ActiveRecord::Base 'backpage', ] + validates_inclusion_of :law_used, :in => [ + 'foi', # Freedom of Information Act + 'eir', # Environmental Information Regulations + ] + def after_initialize if self.described_state.nil? self.described_state = 'waiting_response' end + # FOI or EIR? + if not self.public_body.nil? and self.public_body.eir_only? + self.law_used = 'eir' + end end # Central function to do all searches @@ -128,12 +137,51 @@ public # Subject lines for emails about the request def email_subject_request - 'Freedom of Information request - ' + self.title + self.law_used_full + ' request - ' + self.title end def email_subject_followup - 'Re: Freedom of Information request - ' + self.title + 'Re: ' + self.law_used_full + ' request - ' + self.title end + # Two sorts of laws for requests, FOI or EIR + def law_used_full + if self.law_used == 'foi' + return "Freedom of Information" + elsif self.law_used == 'eir' + return "Environmental Information Regulations" + else + raise "Unknown law used '" + self.law_used + "'" + end + end + def law_used_short + if self.law_used == 'foi' + return "FOI" + elsif self.law_used == 'eir' + return "EIR" + else + raise "Unknown law used '" + self.law_used + "'" + end + end + def law_used_act + if self.law_used == 'foi' + return "Freedom of Information Act" + elsif self.law_used == 'eir' + return "Environmental Information Regulations" + else + raise "Unknown law used '" + self.law_used + "'" + end + end + def law_used_with_a + if self.law_used == 'foi' + return "A Freedom of Information request" + elsif self.law_used == 'eir' + return "An Environmental Information Regulations request" + else + raise "Unknown law used '" + self.law_used + "'" + end + end + + # Return info request corresponding to an incoming email address, or nil if # none found. Checks the hash to ensure the email came from the public body - # only they are sent the email address with the has in it. (We don't check @@ -344,7 +392,7 @@ public return self.public_body.request_email end def recipient_name_and_email - return "FOI requests at " + self.public_body.short_or_long_name + " <" + self.recipient_email + ">" + return self.law_used_short + " requests at " + self.public_body.short_or_long_name + " <" + self.recipient_email + ">" end # History of some things that have happened diff --git a/app/models/public_body.rb b/app/models/public_body.rb index 9b7c97c4c..c13f7d08f 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.72 2008-05-21 22:37:33 francis Exp $ +# $Id: public_body.rb,v 1.73 2008-05-27 01:19:45 francis Exp $ require 'csv' require 'set' @@ -127,6 +127,14 @@ class PublicBody < ActiveRecord::Base def tag_string return self.public_body_tags.map { |t| t.name }.join(' ') end + def has_tag?(tag) + for public_body_tag in self.public_body_tags + if public_body_tag.name == tag + return true + end + end + return false + end # Find all public bodies with a particular tag def self.find_by_tag(tag) @@ -148,6 +156,12 @@ class PublicBody < ActiveRecord::Base end end + # Are all requests to this body under the Environmental Information Regulations? + def eir_only? + return self.has_tag?('eir_only') + end + + class ImportCSVDryRun < StandardError end |