diff options
Diffstat (limited to 'app/controllers')
-rw-r--r-- | app/controllers/body_controller.rb | 7 | ||||
-rw-r--r-- | app/controllers/request_controller.rb | 32 | ||||
-rw-r--r-- | app/controllers/user_controller.rb | 5 |
3 files changed, 30 insertions, 14 deletions
diff --git a/app/controllers/body_controller.rb b/app/controllers/body_controller.rb index 6ad713455..103b500b8 100644 --- a/app/controllers/body_controller.rb +++ b/app/controllers/body_controller.rb @@ -4,11 +4,16 @@ # 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.6 2008-02-27 12:09:03 francis Exp $ +# $Id: body_controller.rb,v 1.7 2008-02-27 13:59:51 francis Exp $ class BodyController < ApplicationController # XXX tidy this up with better error messages, and a more standard infrastructure for the redirect to canonical URL def show + if MySociety::Format.simplify_url_part(params[:url_name]) != params[:url_name] + redirect_to :url_name => MySociety::Format.simplify_url_part(params[:url_name]) + return + end + @public_bodies = PublicBody.find(:all, :conditions => [ "url_name = ?", params[:url_name] ]) if @public_bodies.size > 1 diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb index 3d7e1c869..d02694183 100644 --- a/app/controllers/request_controller.rb +++ b/app/controllers/request_controller.rb @@ -4,12 +4,22 @@ # 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.59 2008-02-25 11:17:29 francis Exp $ +# $Id: request_controller.rb,v 1.60 2008-02-27 13:59:51 francis Exp $ class RequestController < ApplicationController def show - @info_request = InfoRequest.find(params[:id]) + # Look up by old style numeric identifiers + if params[:url_title].match(/^[0-9]+$/) + @info_request = InfoRequest.find(params[:url_title].to_i) + 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]) + + # Other parameters @info_request_events = @info_request.info_request_events @info_request_events.sort! { |a,b| a.created_at <=> b.created_at } @status = @info_request.calculate_status @@ -110,7 +120,7 @@ class RequestController < ApplicationController # XXX send_message needs the database id, so we send after saving, which isn't ideal if the request broke here. @outgoing_message.send_message flash[:notice] = "Your Freedom of Information request has been created and sent on its way." - redirect_to show_request_url(:id => @info_request) + redirect_to show_request_url(:url_title => @info_request.url_title) else # do nothing - as "authenticated?" has done the redirect to signin page for us end @@ -125,7 +135,7 @@ class RequestController < ApplicationController if !params[:submitted_describe_state].nil? flash[:notice] = "The status of this request was made up to date elsewhere while you were filling in the form." end - redirect_to show_request_url(:id => @info_request) + redirect_to show_request_url(:url_title => @info_request.url_title) return end @@ -137,7 +147,7 @@ class RequestController < ApplicationController if @last_info_request_event_id.nil? flash[:notice] = "Internal error - awaiting description, but no event to describe" - redirect_to show_request_url(:id => @info_request) + redirect_to show_request_url(:url_title => @info_request.url_title) return end @@ -169,10 +179,10 @@ class RequestController < ApplicationController # 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 show_request_url(:id => @info_request) + redirect_to show_request_url(:url_title => @info_request.url_title) 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 show_request_url(:id => @info_request) + redirect_to show_request_url(:url_title => @info_request.url_title) 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." @@ -180,17 +190,17 @@ class RequestController < ApplicationController elsif @info_request.calculate_status == 'successful' flash[:notice] = "We're glad you got all the information that you wanted. Thank you for using foi.mysociety.org" # XXX quiz them here for a comment - redirect_to show_request_url(:id => @info_request) + redirect_to show_request_url(:url_title => @info_request.url_title) elsif @info_request.calculate_status == 'partially_successful' flash[:notice] = "We're glad you got some of the information that you wanted." # XXX explain how to complain / quiz them for a comment - redirect_to show_request_url(:id => @info_request) + redirect_to show_request_url(:url_title => @info_request.url_title) 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 == 'requires_admin' flash[:notice] = "Thanks! The foi.mysociety.org team have been notified." - redirect_to show_request_url(:id => @info_request) + redirect_to show_request_url(:url_title => @info_request.url_title) else raise "unknown calculate_status " + @info_request.calculate_status end @@ -242,7 +252,7 @@ class RequestController < ApplicationController @outgoing_message.send_message @outgoing_message.save! flash[:notice] = "Your follow up message has been created and sent on its way." - redirect_to show_request_url(:id => @info_request) + redirect_to show_request_url(:url_title => @info_request.url_title) else # do nothing - as "authenticated?" has done the redirect to signin page for us end diff --git a/app/controllers/user_controller.rb b/app/controllers/user_controller.rb index 50f8ece10..94fe731ba 100644 --- a/app/controllers/user_controller.rb +++ b/app/controllers/user_controller.rb @@ -4,13 +4,14 @@ # Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ # -# $Id: user_controller.rb,v 1.29 2008-02-27 12:20:22 francis Exp $ +# $Id: user_controller.rb,v 1.30 2008-02-27 13:59:52 francis Exp $ class UserController < ApplicationController # Show page about a set of users with same url name def show - if MySociety::Format.simplify_url_part(params[:url_name]) != params[:url_name] + if MySociety::Format.simplify_url_part(params[:url_name]) != params[:url_name] redirect_to :url_name => MySociety::Format.simplify_url_part(params[:url_name]) + return end @display_users = User.find(:all, :conditions => [ "url_name = ?", params[:url_name] ], :order => "created_at desc") |