diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/request_controller.rb | 122 | ||||
-rw-r--r-- | app/models/request_mailer.rb | 6 | ||||
-rw-r--r-- | app/views/request/describe_state.rhtml | 22 |
3 files changed, 65 insertions, 85 deletions
diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb index 9ddfa9090..0a195e30a 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.122 2008-10-16 14:33:17 francis Exp $ +# $Id: request_controller.rb,v 1.123 2008-10-17 16:51:40 francis Exp $ class RequestController < ApplicationController @@ -194,11 +194,17 @@ class RequestController < ApplicationController end end - # Describing state of messages post here + # Submitted to the describing state of messages form def describe_state @info_request = InfoRequest.find(params[:id].to_i) set_last_request(@info_request) + # If this isn't a form submit, go to the request page + if params[:submitted_describe_state].nil? + redirect_to request_url(@info_request) + return + end + # 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? @@ -218,69 +224,65 @@ class RequestController < ApplicationController @is_owning_user = !authenticated_user.nil? && (authenticated_user.id == @info_request.user_id || authenticated_user.owns_every_request?) @new_responses_count = @events_needing_description.select {|i| i.event_type == 'response'}.size - if !params[:submitted_describe_state].nil? - # Check authenticated, and parameters set. We check is_owning_user - # to get admin overrides (see owns_every_request? above) - if !@is_owning_user && !authenticated_as_user?(@info_request.user, - :web => "To classify the response to this FOI request", - :email => "Then you can classify the FOI response you have got from " + @info_request.public_body.name + ".", - :email_subject => "Classify an FOI response from " + @info_request.public_body.name - ) - # do nothing - as "authenticated?" has done the redirect to signin page for us - return - end + # Check authenticated, and parameters set. We check is_owning_user + # to get admin overrides (see owns_every_request? above) + if !@is_owning_user && !authenticated_as_user?(@info_request.user, + :web => "To classify the response to this FOI request", + :email => "Then you can classify the FOI response you have got from " + @info_request.public_body.name + ".", + :email_subject => "Classify an FOI response from " + @info_request.public_body.name + ) + # do nothing - as "authenticated?" has done the redirect to signin page for us + return + end - if !params[:incoming_message] - flash[:error] = "Please choose whether or not you got some of the information that you wanted." - return - end + if !params[:incoming_message] + flash[:error] = "Please choose whether or not you got some of the information that you wanted." + redirect_to request_url(@info_request) + return + end - if params[:last_info_request_event_id].to_i != @last_info_request_event_id - flash[:error] = "The request has been updated since you originally loaded this page. Please check for any new incoming messages below, and try again." - return - end + if params[:last_info_request_event_id].to_i != @last_info_request_event_id + flash[:error] = "The request has been updated since you originally loaded this page. Please check for any new incoming messages below, and try again." + redirect_to request_url(@info_request) + return + end - # Make the state change - @info_request.set_described_state(params[:incoming_message][:described_state]) + # Make the state change + @info_request.set_described_state(params[:incoming_message][:described_state]) - # Display appropriate next page (e.g. help for complaint etc.) - if @info_request.calculate_status == 'waiting_response' - flash[:notice] = "<p>Thank you! Hopefully your wait isn't too long.</p> <p>By law, you should get a response before the end of <strong>" + simple_date(@info_request.date_response_required_by) + "</strong>.</p>" - redirect_to request_url(@info_request) - elsif @info_request.calculate_status == 'waiting_response_overdue' - flash[:notice] = "<p>Thank you! Hope you don't have to wait much longer.</p> <p>By law, you should have got a response before the end of <strong>" + simple_date(@info_request.date_response_required_by) + "</strong>.</p>" - redirect_to request_url(@info_request) - elsif @info_request.calculate_status == 'not_held' - flash[:notice] = "Thank you! You may want to send your request to another public authority. To do so, first copy the text of your request below, then <a href=\"/new\">cick here</a> and find the other authority." - # XXX offer fancier option to duplicate request? - redirect_to request_url(@info_request) - elsif @info_request.calculate_status == 'rejected' - # XXX explain how to complain - flash[:notice] = "Oh no! Sorry to hear that your request was rejected. Here is what to do now." - redirect_to unhappy_url - elsif @info_request.calculate_status == 'successful' - flash[:notice] = "<p>We're glad you got all the information that you wanted. If you write about or make use of the information, please come back and add an annotation below saying what you did.</p><p>If you found WhatDoTheyKnow useful, <a href=\"http://www.mysociety.org/donate/\">make a donation</a> to the charity which runs it.</p>" - # XXX quiz them here for a comment - redirect_to request_url(@info_request) - elsif @info_request.calculate_status == 'partially_successful' - flash[:notice] = "<p>We're glad you got some of the information that you wanted. We have details on what to do if you are <a href=\"/help/unhappy\">unhappy about the response you got</a>.</p><p>If you found WhatDoTheyKnow useful, <a href=\"http://www.mysociety.org/donate/\">make a donation</a> to the charity which runs it.</p>" - # XXX explain how to complain / quiz them for a comment - redirect_to request_url(@info_request) - elsif @info_request.calculate_status == 'waiting_clarification' - flash[:notice] = "Please write your follow up message containing the necessary clarifications below." - redirect_to show_response_url(:id => @info_request.id, :incoming_message_id => @events_needing_description[-1].params[:incoming_message_id]) - 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] = "Please use the form below if you would like to tell us what is unusual about the response." - redirect_to help_general_url(:action => 'contact') - else - raise "unknown calculate_status " + @info_request.calculate_status - end - return + # Display appropriate next page (e.g. help for complaint etc.) + if @info_request.calculate_status == 'waiting_response' + flash[:notice] = "<p>Thank you! Hopefully your wait isn't too long.</p> <p>By law, you should get a response before the end of <strong>" + simple_date(@info_request.date_response_required_by) + "</strong>.</p>" + redirect_to request_url(@info_request) + elsif @info_request.calculate_status == 'waiting_response_overdue' + flash[:notice] = "<p>Thank you! Hope you don't have to wait much longer.</p> <p>By law, you should have got a response before the end of <strong>" + simple_date(@info_request.date_response_required_by) + "</strong>.</p>" + redirect_to request_url(@info_request) + elsif @info_request.calculate_status == 'not_held' + flash[:notice] = "Thank you! You may want to send your request to another public authority. To do so, first copy the text of your request below, then <a href=\"/new\">cick here</a> and find the other authority." + # XXX offer fancier option to duplicate request? + redirect_to request_url(@info_request) + elsif @info_request.calculate_status == 'rejected' + # XXX explain how to complain + flash[:notice] = "Oh no! Sorry to hear that your request was rejected. Here is what to do now." + redirect_to unhappy_url + elsif @info_request.calculate_status == 'successful' + flash[:notice] = "<p>We're glad you got all the information that you wanted. If you write about or make use of the information, please come back and add an annotation below saying what you did.</p><p>If you found WhatDoTheyKnow useful, <a href=\"http://www.mysociety.org/donate/\">make a donation</a> to the charity which runs it.</p>" + # XXX quiz them here for a comment + redirect_to request_url(@info_request) + elsif @info_request.calculate_status == 'partially_successful' + flash[:notice] = "<p>We're glad you got some of the information that you wanted. We have details on what to do if you are <a href=\"/help/unhappy\">unhappy about the response you got</a>.</p><p>If you found WhatDoTheyKnow useful, <a href=\"http://www.mysociety.org/donate/\">make a donation</a> to the charity which runs it.</p>" + # XXX explain how to complain / quiz them for a comment + redirect_to request_url(@info_request) + elsif @info_request.calculate_status == 'waiting_clarification' + flash[:notice] = "Please write your follow up message containing the necessary clarifications below." + redirect_to show_response_url(:id => @info_request.id, :incoming_message_id => @events_needing_description[-1].params[:incoming_message_id]) + 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] = "Please use the form below if you would like to tell us what is unusual about the response." + redirect_to help_general_url(:action => 'contact') else - # Display default template - return + raise "unknown calculate_status " + @info_request.calculate_status end end diff --git a/app/models/request_mailer.rb b/app/models/request_mailer.rb index 316567e60..aa2b2663a 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.62 2008-10-17 07:02:01 francis Exp $ +# $Id: request_mailer.rb,v 1.63 2008-10-17 16:51:41 francis Exp $ class RequestMailer < ApplicationMailer @@ -107,7 +107,7 @@ class RequestMailer < ApplicationMailer # Tell the requester that a new response has arrived def new_response(info_request, incoming_message) post_redirect = PostRedirect.new( - :uri => describe_state_url(:id => info_request.id), + :uri => main_url(incoming_message_url(incoming_message)), :user_id => info_request.user.id) post_redirect.save! url = confirm_url(:email_token => post_redirect.email_token) @@ -138,7 +138,7 @@ class RequestMailer < ApplicationMailer # contains info or not def new_response_reminder_alert(info_request, incoming_message) post_redirect = PostRedirect.new( - :uri => describe_state_url(:id => info_request.id), + :uri => main_url(incoming_message_url(incoming_message)), :user_id => info_request.user.id) post_redirect.save! url = confirm_url(:email_token => post_redirect.email_token) diff --git a/app/views/request/describe_state.rhtml b/app/views/request/describe_state.rhtml deleted file mode 100644 index e65823e3e..000000000 --- a/app/views/request/describe_state.rhtml +++ /dev/null @@ -1,22 +0,0 @@ -<% @title = MySociety::Format.fancy_pluralize(@new_responses_count, 'New response', 'new responses') + - " to '" + h(@info_request.title) + "'" %> - -<%= foi_error_messages_for :incoming_message, :outgoing_message %> - -<div class="describe_state_form"> - <%= render :partial => 'describe_state', :locals => { :id_suffix => "1" } %> -</div> - -<div id="show_response_view"> - <h2><%=MySociety::Format.fancy_pluralize(@new_responses_count, 'New response', 'new responses') %> - to your request '<%= request_link @info_request %>'</h2> - - <% for info_request_event in @events_needing_description %> - <%= render :partial => 'correspondence', :locals => { :info_request_event => info_request_event } %> - <% end %> -</div> - -<div class="describe_state_form"> - <%= render :partial => 'describe_state', :locals => { :id_suffix => "2" } %> -</div> - |