diff options
-rw-r--r-- | app/controllers/request_controller.rb | 12 | ||||
-rw-r--r-- | app/models/incoming_message.rb | 6 | ||||
-rw-r--r-- | app/models/public_body.rb | 19 | ||||
-rw-r--r-- | app/views/admin_public_body/_form.rhtml | 2 | ||||
-rw-r--r-- | app/views/request/new_bad_contact.rhtml | 1 | ||||
-rw-r--r-- | app/views/request/new_not_apply.rhtml | 15 |
6 files changed, 43 insertions, 12 deletions
diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb index 1c9c36f74..f01f514a1 100644 --- a/app/controllers/request_controller.rb +++ b/app/controllers/request_controller.rb @@ -4,7 +4,7 @@ # Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ # -# $Id: request_controller.rb,v 1.93 2008-05-27 08:56:27 francis Exp $ +# $Id: request_controller.rb,v 1.94 2008-06-23 23:20:45 francis Exp $ class RequestController < ApplicationController @@ -82,10 +82,10 @@ class RequestController < ApplicationController if @info_request.public_body.nil? redirect_to frontpage_url else - if @info_request.public_body.request_email.empty? - render :action => 'new_bad_contact' - else + if @info_request.public_body.is_requestable? render :action => 'new' + else + render :action => 'new_' + @info_request.public_body.not_requestable_reason end end return @@ -107,8 +107,8 @@ class RequestController < ApplicationController @outgoing_message.info_request = @info_request # Maybe we lost the address while they're writing it - if @info_request.public_body.request_email.empty? - render :action => 'new_bad_contact' + if not @info_request.public_body.is_requestable? + render :action => 'new_' + @info_request.public_body.not_requestable_reason return end 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 diff --git a/app/views/admin_public_body/_form.rhtml b/app/views/admin_public_body/_form.rhtml index d53ab8134..fa84a2e96 100644 --- a/app/views/admin_public_body/_form.rhtml +++ b/app/views/admin_public_body/_form.rhtml @@ -15,7 +15,7 @@ <%= text_field 'public_body', 'tag_string', :size => 80 %></p> -<p><label for="public_body_request_email">Request email (set to blank if an old address became bad and you can't find a new one)</label><br/> +<p><label for="public_body_request_email">Request email (set to <strong>blank</strong> (empty string) if can't find an address; to <strong>not_apply</strong> if FOI no longer / never did apply to authority)</label><br/> <%= text_field 'public_body', 'request_email', :size => 40 %></p> <p><label for="public_body_last_edit_comment">Comment for this edit</label> (put URL or other source of new info)<br/> diff --git a/app/views/request/new_bad_contact.rhtml b/app/views/request/new_bad_contact.rhtml index 7211165e4..c1433fee6 100644 --- a/app/views/request/new_bad_contact.rhtml +++ b/app/views/request/new_bad_contact.rhtml @@ -6,4 +6,5 @@ address for <%=h @info_request.public_body.name %>. You may be able to find one on their website, or by phoning them up and asking. If you mange to find one, then please <a href="/help/contact">send it to us</a>. +</p> diff --git a/app/views/request/new_not_apply.rhtml b/app/views/request/new_not_apply.rhtml new file mode 100644 index 000000000..1b5ff504f --- /dev/null +++ b/app/views/request/new_not_apply.rhtml @@ -0,0 +1,15 @@ +<% @title = "Freedom of Information law does not apply to '" + h(@info_request.public_body.name) + "'" %> + +<h1><%=@title%></h1> + +<p>Unfortunately, Freedom of Information law does not apply to +<%=h @info_request.public_body.name %>. It appears on this +site because we either incorrectly added it, or FOI +used to apply to it but doesn't any more. +</p> + +<p>Perhaps you can get the same information by making a request +to a Government department relevant to <%=h @info_request.public_body.name %>, +or to another public authority with whom they have links. +</p> + |