aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/controllers/request_controller.rb16
-rw-r--r--app/models/public_body.rb12
-rw-r--r--app/views/admin/index.rhtml2
-rw-r--r--app/views/admin_public_body/_form.rhtml2
-rw-r--r--app/views/request/new_bad_contact.rhtml9
5 files changed, 31 insertions, 10 deletions
diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb
index 677633588..7fe9feda5 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.67 2008-03-16 23:32:10 francis Exp $
+# $Id: request_controller.rb,v 1.68 2008-03-17 10:36:41 francis Exp $
class RequestController < ApplicationController
@@ -44,7 +44,7 @@ class RequestController < ApplicationController
def new
# First time we get to the page, just display it
if params[:submitted_new_request].nil? or params[:reedit]
- # Read parameters in - public body can be passed from front page
+ # Read parameters in - public body must be passed in
if params[:public_body_id]
params[:info_request] = { :public_body_id => params[:public_body_id] }
end
@@ -54,7 +54,11 @@ class RequestController < ApplicationController
if @info_request.public_body.nil?
redirect_to frontpage_url
else
- render :action => 'new'
+ if @info_request.public_body.request_email.empty?
+ render :action => 'new_bad_contact'
+ else
+ render :action => 'new'
+ end
end
return
end
@@ -74,6 +78,12 @@ class RequestController < ApplicationController
@info_request.outgoing_messages << @outgoing_message
@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'
+ return
+ end
+
# See if values were valid or not
if !@existing_request.nil? || !@info_request.valid?
# We don't want the error "Outgoing messages is invalid", as the outgoing message
diff --git a/app/models/public_body.rb b/app/models/public_body.rb
index 9c5fe6927..768da2a79 100644
--- a/app/models/public_body.rb
+++ b/app/models/public_body.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: public_body.rb,v 1.36 2008-03-13 11:29:47 francis Exp $
+# $Id: public_body.rb,v 1.37 2008-03-17 10:36:43 francis Exp $
require 'csv'
require 'set'
@@ -30,8 +30,7 @@ require 'set'
class PublicBody < ActiveRecord::Base
validates_presence_of :name
validates_presence_of :url_name
- validates_presence_of :request_email
-
+
has_many :info_requests
has_many :public_body_tags
@@ -46,8 +45,11 @@ class PublicBody < ActiveRecord::Base
end
def validate
- unless MySociety::Validate.is_valid_email(self.request_email)
- errors.add(:request_email, "doesn't look like a valid email address")
+ # Request_email can be blank, meaning we don't have details
+ if self.request_email != ""
+ unless MySociety::Validate.is_valid_email(self.request_email)
+ errors.add(:request_email, "doesn't look like a valid email address")
+ end
end
if self.complaint_email != ""
unless MySociety::Validate.is_valid_email(self.complaint_email)
diff --git a/app/views/admin/index.rhtml b/app/views/admin/index.rhtml
index ab41731c9..f5308b35a 100644
--- a/app/views/admin/index.rhtml
+++ b/app/views/admin/index.rhtml
@@ -20,7 +20,7 @@
<% if last_date.nil? %>
<p>
<% end %>
- <h2><%= simple_date(event.created_at) %></h2>
+ <h3><%= simple_date(event.created_at) %></h3>
<p>
<% else %>
<br>
diff --git a/app/views/admin_public_body/_form.rhtml b/app/views/admin_public_body/_form.rhtml
index 24322d3ea..4f1ede2cc 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</label><br/>
+<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/>
<%= text_field 'public_body', 'request_email', :size => 40 %></p>
<p><label for="public_body_complaint_email">Complaint email</label><br/>
diff --git a/app/views/request/new_bad_contact.rhtml b/app/views/request/new_bad_contact.rhtml
new file mode 100644
index 000000000..51ca87652
--- /dev/null
+++ b/app/views/request/new_bad_contact.rhtml
@@ -0,0 +1,9 @@
+<% @title = "Missing contact details for '" + h(@info_request.public_body.name) + "'" %>
+
+<h1><%=@title%></h1>
+
+<p>Unfortunately, we do not have a working Freedom of Information email
+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>.
+