aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfrancis <francis>2008-10-07 22:05:05 +0000
committerfrancis <francis>2008-10-07 22:05:05 +0000
commitb802d138ea3559bc8eea08ce6d7fd542be6478d5 (patch)
treec12577831b9a104c07710ba6beeb36d9fe43b6bb
parenta70a725316ec8c21522dd921c9a0c863577defe9 (diff)
Put URL of last viewed request / authority in contact form emails.
Get rid of details box for requires_admin, as people were using it unnecessarily, instead direct to contact form on next page.
-rw-r--r--app/controllers/application.rb15
-rw-r--r--app/controllers/body_controller.rb3
-rw-r--r--app/controllers/help_controller.rb33
-rw-r--r--app/controllers/request_controller.rb15
-rw-r--r--app/models/contact_mailer.rb8
-rw-r--r--app/views/contact_mailer/message.rhtml9
-rw-r--r--app/views/help/contact.rhtml60
-rw-r--r--app/views/request/_describe_state.rhtml3
-rw-r--r--todo.txt5
9 files changed, 108 insertions, 43 deletions
diff --git a/app/controllers/application.rb b/app/controllers/application.rb
index ae2c8dd6f..c6f346907 100644
--- a/app/controllers/application.rb
+++ b/app/controllers/application.rb
@@ -6,7 +6,7 @@
# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved.
# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
#
-# $Id: application.rb,v 1.50 2008-09-12 08:26:04 francis Exp $
+# $Id: application.rb,v 1.51 2008-10-07 22:05:06 francis Exp $
class ApplicationController < ActionController::Base
@@ -213,12 +213,19 @@ class ApplicationController < ActionController::Base
return InfoRequest.full_search(models, @query, order, ascending, collapse, @per_page, @page)
end
+ # Store last visited pages, for contact form
+ def set_last_request(info_request)
+ session[:last_request_id] = info_request.id
+ session[:last_body_id] = nil
+ end
+ def set_last_body(public_body)
+ session[:last_request_id] = nil
+ session[:last_body_id] = public_body.id
+ end
+
# URL generating functions are needed by all controllers (for redirects),
# views (for links) and mailers (for use in emails), so include them into
# all of all.
include LinkToHelper
end
-
-
-
diff --git a/app/controllers/body_controller.rb b/app/controllers/body_controller.rb
index b2addd045..1b113252f 100644
--- a/app/controllers/body_controller.rb
+++ b/app/controllers/body_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: body_controller.rb,v 1.17 2008-09-13 15:35:37 francis Exp $
+# $Id: body_controller.rb,v 1.18 2008-10-07 22:05:06 francis Exp $
class BodyController < ApplicationController
# XXX tidy this up with better error messages, and a more standard infrastructure for the redirect to canonical URL
@@ -32,6 +32,7 @@ class BodyController < ApplicationController
redirect_to show_public_body_url(:url_name => @public_bodies[0].url_name)
end
@public_body = @public_bodies[0]
+ set_last_body(@public_body)
@track_thing = TrackThing.create_track_for_public_body(@public_body)
@feed_autodetect = [ { :url => do_track_url(@track_thing, 'feed'), :title => @track_thing.params[:title_in_rss] } ]
diff --git a/app/controllers/help_controller.rb b/app/controllers/help_controller.rb
index 0ba7da12d..5fc039b3e 100644
--- a/app/controllers/help_controller.rb
+++ b/app/controllers/help_controller.rb
@@ -4,7 +4,7 @@
# Copyright (c) 2008 UK Citizens Online Democracy. All rights reserved.
# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
#
-# $Id: help_controller.rb,v 1.8 2008-10-03 17:48:37 francis Exp $
+# $Id: help_controller.rb,v 1.9 2008-10-07 22:05:06 francis Exp $
class HelpController < ApplicationController
@@ -15,24 +15,51 @@ class HelpController < ApplicationController
@contact_email = MySociety::Config.get("CONTACT_EMAIL", 'contact@localhost')
@contact_email = @contact_email.gsub(/@/, "&#64;")
+ # if they clicked remove for link to request/body, remove it
+ if params[:remove]
+ @last_request = nil
+ session[:last_request_id] = nil
+ session[:last_body_id] = nil
+ end
+
+ # look up link to request/body
+ @last_request_id = session[:last_request_id].to_i
+ if @last_request_id > 0
+ @last_request = InfoRequest.find(@last_request_id)
+ else
+ @last_request = nil
+ end
+ @last_body_id = session[:last_body_id].to_i
+ if @last_body_id > 0
+ @last_body = PublicBody.find(@last_body_id)
+ else
+ @last_body = nil
+ end
+
+ # submit form
if params[:submitted_contact_form]
if @user
params[:contact][:email] = @user.email
params[:contact][:name] = @user.name
end
@contact = ContactValidator.new(params[:contact])
- if @contact.valid?
+ if @contact.valid? && !params[:remove]
ContactMailer.deliver_message(
params[:contact][:name],
params[:contact][:email],
params[:contact][:subject],
params[:contact][:message],
- @user
+ @user,
+ @last_request, @last_body
)
flash[:notice] = "Your message has been sent. Thank you for getting in touch! We'll get back to you soon."
redirect_to frontpage_url
return
end
+
+ if params[:remove]
+ @contact.errors.clear
+ end
end
end
diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb
index bb3bd8b85..2b6ff0400 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.117 2008-10-03 17:09:05 francis Exp $
+# $Id: request_controller.rb,v 1.118 2008-10-07 22:05:06 francis Exp $
class RequestController < ApplicationController
@@ -15,9 +15,10 @@ class RequestController < ApplicationController
redirect_to request_url(@info_request)
return
end
-
+
# Look up by new style text names
@info_request = InfoRequest.find_by_url_title(params[:url_title])
+ set_last_request(@info_request)
# Other parameters
@info_request_events = @info_request.info_request_events
@@ -195,7 +196,8 @@ class RequestController < ApplicationController
# Describing state of messages post here
def describe_state
- @info_request = InfoRequest.find(params[:id])
+ @info_request = InfoRequest.find(params[:id].to_i)
+ set_last_request(@info_request)
# special case that an admin user can edit requires_admin requests
@requires_admin_describe = (@info_request.described_state == 'requires_admin') && !authenticated_user.nil? && authenticated_user.requires_admin_power?
@@ -270,8 +272,8 @@ class RequestController < ApplicationController
elsif @info_request.calculate_status == 'gone_postal'
redirect_to respond_to_last_url(@info_request) + "?gone_postal=1"
elsif @info_request.calculate_status == 'requires_admin'
- flash[:notice] = "Thanks! The WhatDoTheyKnow team have been notified. <a href=\"/help/contact\">Contact us</a> if you have more to say about how we should handle this."
- redirect_to request_url(@info_request)
+ flash[:notice] = "Please use the form below to tell us details about what is unusual about the response."
+ redirect_to help_general_url(:action => 'contact')
else
raise "unknown calculate_status " + @info_request.calculate_status
end
@@ -303,7 +305,10 @@ class RequestController < ApplicationController
else
@incoming_message = IncomingMessage.find(params[:incoming_message_id])
end
+
@info_request = InfoRequest.find(params[:id].to_i)
+ set_last_request(@info_request)
+
@collapse_quotes = params[:unfold] ? false : true
@is_owning_user = !authenticated_user.nil? && (authenticated_user.id == @info_request.user_id || authenticated_user.owns_every_request?)
@gone_postal = params[:gone_postal] ? true : false
diff --git a/app/models/contact_mailer.rb b/app/models/contact_mailer.rb
index f0fb37d20..179e00c54 100644
--- a/app/models/contact_mailer.rb
+++ b/app/models/contact_mailer.rb
@@ -4,17 +4,19 @@
# Copyright (c) 2008 UK Citizens Online Democracy. All rights reserved.
# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
#
-# $Id: contact_mailer.rb,v 1.8 2008-10-03 17:48:37 francis Exp $
+# $Id: contact_mailer.rb,v 1.9 2008-10-07 22:05:06 francis Exp $
class ContactMailer < ApplicationMailer
# Send message to administrator
- def message(name, email, subject, message, logged_in_user)
+ def message(name, email, subject, message, logged_in_user, last_request, last_body)
@from = name + " <" + email + ">"
@recipients = contact_from_name_and_email
@subject = subject
@body = { :message => message,
- :logged_in_user => logged_in_user
+ :logged_in_user => logged_in_user ,
+ :last_request => last_request,
+ :last_body => last_body
}
end
diff --git a/app/views/contact_mailer/message.rhtml b/app/views/contact_mailer/message.rhtml
index 54303cdd5..ad868ec5b 100644
--- a/app/views/contact_mailer/message.rhtml
+++ b/app/views/contact_mailer/message.rhtml
@@ -2,5 +2,10 @@
---------------------------------------------------------------------
Message sent using WhatDoTheyKnow contact form,
-<%=(@logged_in_user ? ("logged in as user " + main_url(user_url(@logged_in_user))) : "not logged in")%>
----------------------------------------------------------------------
+<%=(@logged_in_user ? ("logged in as user " + main_url(user_url(@logged_in_user))) : "not logged in")%><% if !@last_request.nil? %>
+
+Last request viewed: <%= main_url(request_url(@last_request)) %>
+<% end %> <% if !@last_body.nil? %>
+
+Last authority viewed: <%= main_url(public_body_url(@last_body)) %>
+<% end %>---------------------------------------------------------------------
diff --git a/app/views/help/contact.rhtml b/app/views/help/contact.rhtml
index c031fbc4b..62d8cf465 100644
--- a/app/views/help/contact.rhtml
+++ b/app/views/help/contact.rhtml
@@ -4,32 +4,35 @@
<div id="contact_preamble">
- <h1>Make a request for public, official information</h1>
- <p>
- <a href="/new">Go here</a> to make your request, in public, for information
- from UK public authorities.
- </p>
+ <% if !flash[:notice] %>
+ <h1>Make a request for public, official information</h1>
+ <p>
+ <a href="/new">Go here</a> to make your request, in public, for information
+ from UK public authorities.
+ </p>
- <h1>Request information about yourself</h1>
- <p>
- Our help page about <a href="/help/about#data_protection">data protection</a>
- explains how to request information about yourself from UK public authorities.
- </p>
+ <h1>Request information about yourself</h1>
+ <p>
+ Our help page about <a href="/help/about#data_protection">data protection</a>
+ explains how to request information about yourself from UK public authorities.
+ </p>
+ <% end %>
<h1>Contact the WhatDoTheyKnow team</h1>
- <p>
- We'd love to hear how you have found using this site.
- </p>
- <p>
- Please read the <a href="/help/about">about page</a> first, as it may
- answer your question quicker. Then fill in this form, or send
- an email to <a href="mailto:<%=@contact_email%>"><%=@contact_email%></a>
- </p>
+ <% if !flash[:notice] %>
+ <p>
+ We'd love to hear how you have found using this site.
+ </p>
+ <p>
+ Please read the <a href="/help/about">about page</a> first, as it may
+ answer your question quicker. Then fill in this form, or send
+ an email to <a href="mailto:<%=@contact_email%>"><%=@contact_email%></a>
+ </p>
+ <% end %>
</div>
<% form_for :contact do |f| %>
-
<% if not @user %>
<p>
<label class="form_label" for="contact_name">Your name:</label>
@@ -53,10 +56,21 @@
<%= f.text_area :message, :rows => 10, :cols => 60 %>
</p>
- <p class="form_note">
- If you are referring to a specific request or authority, it would
- be helpful if you could include a link to it in your message.
- </p>
+ <% if !@last_request.nil? %>
+ <p>
+ <label class="form_label" for="contact_message">Include link to request:</label>
+ <%=request_link(@last_request) %>
+ <%= submit_tag "remove", :name => 'remove' %>
+ </p>
+ <% end %>
+ <% if !@last_body.nil? %>
+ <p>
+ <label class="form_label" for="contact_message">Include link to authority:</label>
+ <%=public_body_link(@last_body) %>
+ <%= submit_tag "remove", :name => 'remove' %>
+ </p>
+ <% end %>
+
<div class="form_button">
<%= hidden_field_tag(:submitted_contact_form, 1) %>
diff --git a/app/views/request/_describe_state.rhtml b/app/views/request/_describe_state.rhtml
index 2eea28bbd..b5e1c088e 100644
--- a/app/views/request/_describe_state.rhtml
+++ b/app/views/request/_describe_state.rhtml
@@ -34,8 +34,7 @@
<hr>
<div>
<%= radio_button "incoming_message", "described_state", "requires_admin", :id => 'requires_admin' + id_suffix %>
- <label for="requires_admin<%=id_suffix%>"><strong>None</strong> of the above - enter quick summary here:</label>
- <%= text_field "incoming_message", 'requires_admin_details', :class => 'requires_admin_details', :id => 'requires_admin_details' + id_suffix, :size => 60 %>
+ <label for="requires_admin<%=id_suffix%>"><strong>None</strong> of the above (please read them first!)</label>
</div>
<hr>
<p>Filling this in helps everyone track the progress of your request.
diff --git a/todo.txt b/todo.txt
index 5074ee453..cc1b85269 100644
--- a/todo.txt
+++ b/todo.txt
@@ -1,5 +1,7 @@
Test data for Tony
+XXX remove details from set_described_state
+
Next
====
@@ -244,6 +246,7 @@ Quoting fixing TODO:
http://www.whatdotheyknow.com/request/please_submit_the_surveyors_repo#incoming-6334 # charset
http://www.whatdotheyknow.com/request/enforcement_forders_for_replacin#incoming-6277 # over zealous quoting
+ http://www.whatdotheyknow.com/request/renewable_energy_consumption_by # over zealous
Larger new features
@@ -266,6 +269,8 @@ Editable user profile, including photo upload
HTML versions of all attachments, so links like in GMail
Somthing.doc
20K View as HTML Open as a Google document Download
+Maybe use Google API for the open in Google link. Not sure though.
+ http://code.google.com/apis/documents/developers_guide_python.html#UploadingDocs
.tif files are hard for people to view as multi page, consider automatically
separating out the pages as separate links (to .png files or whatever)