aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/controllers/request_controller.rb10
-rw-r--r--app/models/request_mailer.rb4
-rw-r--r--app/views/request/_correspondence.rhtml2
-rw-r--r--app/views/request/show_response.rhtml (renamed from app/views/request/classify.rhtml)6
-rw-r--r--config/routes.rb4
-rw-r--r--public/stylesheets/main.css6
-rw-r--r--spec/controllers/request_controller_spec.rb14
7 files changed, 25 insertions, 21 deletions
diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb
index 843446032..d1698c787 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.31 2008-01-09 15:35:40 francis Exp $
+# $Id: request_controller.rb,v 1.32 2008-01-09 19:34:07 francis Exp $
class RequestController < ApplicationController
@@ -73,12 +73,16 @@ class RequestController < ApplicationController
end
end
- # Did the incoming message contain info?
- def classify
+ # Show an individual incoming message, and let the user classify it.
+ def show_response
@incoming_message = IncomingMessage.find(params[:incoming_message_id])
@info_request = @incoming_message.info_request
@collapse_quotes = params[:unfold] ? false : true
+ if @incoming_message.info_request_id != params[:id].to_i
+ raise sprintf("Incoming message %d does not belong to request %d", @incoming_message.info_request_id, params[:id])
+ end
+
if not authenticated_as_user?(@info_request.user,
:web => "To view and classify the response to this FOI request",
:email => "Then you can classify the FOI response you have got from " + @info_request.public_body.name + ".",
diff --git a/app/models/request_mailer.rb b/app/models/request_mailer.rb
index 13bb5fdab..f6b34c120 100644
--- a/app/models/request_mailer.rb
+++ b/app/models/request_mailer.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_mailer.rb,v 1.14 2008-01-03 18:21:30 francis Exp $
+# $Id: request_mailer.rb,v 1.15 2008-01-09 19:34:07 francis Exp $
class RequestMailer < ActionMailer::Base
@@ -26,7 +26,7 @@ class RequestMailer < ActionMailer::Base
def new_response(info_request, incoming_message)
post_redirect = PostRedirect.new(
- :uri => classify_request_url(:incoming_message_id => incoming_message.id),
+ :uri => show_response_url(:id => info_request.id, :incoming_message_id => incoming_message.id),
:user_id => info_request.user.id)
post_redirect.save!
url = confirm_url(:email_token => post_redirect.email_token)
diff --git a/app/views/request/_correspondence.rhtml b/app/views/request/_correspondence.rhtml
index f3f39be7a..d087aa87a 100644
--- a/app/views/request/_correspondence.rhtml
+++ b/app/views/request/_correspondence.rhtml
@@ -20,7 +20,7 @@
<% end %>
on <strong><%= simple_date(incoming_message.sent_at) %></strong>
<% if not incoming_message.user_classified %>
- &mdash; please <%= link_to "classify this response", classify_request_url(:incoming_message_id => incoming_message.id) %>
+ &mdash; please <%= link_to "classify this response", show_response_url(:id => incoming_message.info_request.id, :incoming_message_id => incoming_message.id) %>
<% end %>
</p>
<% elsif (correspondence.class.to_s == 'InfoRequestEvent')
diff --git a/app/views/request/classify.rhtml b/app/views/request/show_response.rhtml
index 15789858e..a7fa90e6f 100644
--- a/app/views/request/classify.rhtml
+++ b/app/views/request/show_response.rhtml
@@ -1,15 +1,15 @@
-<% @title = "Classify FOI response" %>
+<% @title = "View and classify FOI response" %>
<%= foi_error_messages_for :incoming_message %>
-<div id="classify_view">
+<div id="show_response_view">
<h2>New response to your request '<%= request_link @info_request %>'</h2>
<%= render :partial => 'correspondence', :locals => { :correspondence => @incoming_message } %>
</div>
<% if not @incoming_message.user_classified %>
- <div id="classify_action">
+ <div id="show_response_classify_action">
<%= render :partial => 'classify' %>
<div>
<% end %>
diff --git a/config/routes.rb b/config/routes.rb
index 0dd6976e6..d52b4ef76 100644
--- a/config/routes.rb
+++ b/config/routes.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: routes.rb,v 1.27 2008-01-09 15:35:41 francis Exp $
+# $Id: routes.rb,v 1.28 2008-01-09 19:34:07 francis Exp $
ActionController::Routing::Routes.draw do |map|
# The priority is based upon order of creation: first created -> highest priority.
@@ -18,7 +18,7 @@ ActionController::Routing::Routes.draw do |map|
request.request_list '/list', :action => 'list'
request.new_request '/new', :action => 'new'
request.show_request '/request/:id', :action => 'show'
- request.classify_request '/classify/:incoming_message_id', :action => 'classify'
+ request.show_response '/request/:id/response/:incoming_message_id', :action => 'show_response'
end
map.with_options :controller => 'user' do |user|
diff --git a/public/stylesheets/main.css b/public/stylesheets/main.css
index 49e3cc4a3..364a641dd 100644
--- a/public/stylesheets/main.css
+++ b/public/stylesheets/main.css
@@ -280,14 +280,14 @@ table#list_requests .odd {
display: none;
}
-/* /classify - classifying requests */
+/* /show_response - viewing and classifying individual responses */
-#classify_action {
+#show_response_classify_action {
float: left;
width: 35%;
}
-#classify_view {
+#show_response_view {
float: right;
width: 60%;
}
diff --git a/spec/controllers/request_controller_spec.rb b/spec/controllers/request_controller_spec.rb
index 1e20ca8ab..22d451611 100644
--- a/spec/controllers/request_controller_spec.rb
+++ b/spec/controllers/request_controller_spec.rb
@@ -148,21 +148,21 @@ describe RequestController, "when viewing an individual response" do
fixtures :info_requests, :public_bodies, :users, :incoming_messages, :outgoing_messages # all needed as integrating views
it "should require login if not logged in" do
- get :classify, :incoming_message_id => 1
+ get :show_response, :id => info_requests(:fancy_dog_request).id, :incoming_message_id => incoming_messages(:useless_incoming_message)
post_redirect = PostRedirect.get_last_post_redirect
response.should redirect_to(:controller => 'user', :action => 'signin', :token => post_redirect.token)
end
it "should say you are the wrong user if logged in as wrong user" do
session[:user_id] = users(:silly_name_user).id
- get :classify, :incoming_message_id => 1
+ get :show_response, :id => info_requests(:fancy_dog_request).id, :incoming_message_id => incoming_messages(:useless_incoming_message)
response.should render_template('user/wrong_user')
end
it "should show classification page if logged in as user controlling request" do
session[:user_id] = users(:bob_smith_user).id
- get :classify, :incoming_message_id => 1
- response.should render_template('classify')
+ get :show_response, :id => info_requests(:fancy_dog_request).id, :incoming_message_id => incoming_messages(:useless_incoming_message)
+ response.should render_template('show_response')
end
end
@@ -171,21 +171,21 @@ describe RequestController, "when classifying an individual response" do
fixtures :info_requests, :public_bodies, :users, :incoming_messages, :outgoing_messages # all needed as integrating views
it "should require login" do
- post :classify, :incoming_message => { :contains_information => true }, :incoming_message_id => incoming_messages(:useless_incoming_message)
+ post :show_response, :incoming_message => { :contains_information => true }, :id => info_requests(:fancy_dog_request).id, :incoming_message_id => incoming_messages(:useless_incoming_message)
post_redirect = PostRedirect.get_last_post_redirect
response.should redirect_to(:controller => 'user', :action => 'signin', :token => post_redirect.token)
end
it "should not classify response if logged in as wrong user" do
session[:user_id] = users(:silly_name_user).id
- post :classify, :incoming_message => { :contains_information => true }, :incoming_message_id => incoming_messages(:useless_incoming_message)
+ post :show_response, :incoming_message => { :contains_information => true }, :id => info_requests(:fancy_dog_request).id, :incoming_message_id => incoming_messages(:useless_incoming_message)
response.should render_template('user/wrong_user')
end
it "should successfully classify response if logged in as user controlling request" do
incoming_messages(:useless_incoming_message).user_classified.should == false
session[:user_id] = users(:bob_smith_user).id
- post :classify, :incoming_message => { :contains_information => true }, :incoming_message_id => incoming_messages(:useless_incoming_message)
+ post :show_response, :incoming_message => { :contains_information => true }, :id => info_requests(:fancy_dog_request).id, :incoming_message_id => incoming_messages(:useless_incoming_message)
response.should redirect_to(:controller => 'request', :action => 'show', :id => info_requests(:fancy_dog_request))
incoming_messages(:useless_incoming_message).reload
incoming_messages(:useless_incoming_message).user_classified.should == true