diff options
author | Francis Irving <francis@mysociety.org> | 2010-10-04 01:09:52 +0100 |
---|---|---|
committer | Francis Irving <francis@mysociety.org> | 2010-10-04 01:09:52 +0100 |
commit | a6e8aba3630eb1d0da5c36ae176e8bfe478cb851 (patch) | |
tree | 3fd82864ac559d0b40f198d0e0268093e6402fb1 | |
parent | 645b18cb01af25c9f0e9fe003fdf5c768d6f18fd (diff) |
Use URL name rather than internal identifier for new requests.
-rw-r--r-- | app/controllers/request_controller.rb | 26 | ||||
-rw-r--r-- | app/views/public_body/show.rhtml | 4 | ||||
-rw-r--r-- | app/views/public_body/view_email.rhtml | 4 | ||||
-rw-r--r-- | app/views/request/_followup.rhtml | 2 | ||||
-rw-r--r-- | config/routes.rb | 2 | ||||
-rw-r--r-- | todo.txt | 4 |
6 files changed, 30 insertions, 12 deletions
diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb index 0b47999df..382575a06 100644 --- a/app/controllers/request_controller.rb +++ b/app/controllers/request_controller.rb @@ -168,17 +168,31 @@ class RequestController < ApplicationController # First time we get to the page, just display it if params[:submitted_new_request].nil? || params[:reedit] - # Read parameters in - public body must be passed in - if !params[:info_request] - params[:info_request] = { - :public_body_id => params[:public_body_id], - :tag_string => params[:tags] - } + params[:info_request] = { } if !params[:info_request] + + # Read parameters in - first the public body (by URL name or id) + if params[:url_name] + if params[:url_name].match(/^[0-9]+$/) + params[:info_request][:public_body_id] = params[:url_name] + else + public_body = PublicBody.find_by_url_name_with_historic(params[:url_name]) + raise "None found" if public_body.nil? # XXX proper 404 + params[:info_request][:public_body_id] = public_body.id + end + elsif params[:public_body_id] + params[:info_request][:public_body_id] = params[:public_body_id] end if !params[:info_request][:public_body_id] + # compulsory to have a body by here, or go to front page which is start of process redirect_to frontpage_url return end + + # ... next any tags + if params[:tags] + params[:info_request][:tag_string] = params[:tags] + end + @info_request = InfoRequest.new(params[:info_request]) params[:info_request_id] = @info_request.id params[:outgoing_message] = {} if !params[:outgoing_message] diff --git a/app/views/public_body/show.rhtml b/app/views/public_body/show.rhtml index e6fe61a0a..c1deea762 100644 --- a/app/views/public_body/show.rhtml +++ b/app/views/public_body/show.rhtml @@ -48,9 +48,9 @@ <% make = 'make' %> <% end %> <% if @public_body.eir_only? %> - <%= link_to make + " a new Environmental Information request", new_request_to_body_url(:public_body_id => @public_body.id.to_s)%> + <%= link_to make + " a new Environmental Information request", new_request_to_body_url(:url_name => @public_body.url_name)%> <% else %> - <%= link_to make + " a new Freedom of Information request", new_request_to_body_url(:public_body_id => @public_body.id.to_s)%> + <%= link_to make + " a new Freedom of Information request", new_request_to_body_url(:url_name => @public_body.url_name)%> <% end %> to <%= h(@public_body.name) %> <% elsif @public_body.has_notes? %> diff --git a/app/views/public_body/view_email.rhtml b/app/views/public_body/view_email.rhtml index 47cfe0da8..2bd7c38c4 100644 --- a/app/views/public_body/view_email.rhtml +++ b/app/views/public_body/view_email.rhtml @@ -36,9 +36,9 @@ <div id="stepwise_make_request_view_email"> <strong> <% if @public_body.eir_only? %> - <%= link_to "Make a new EIR request", new_request_to_body_url(:public_body_id => @public_body.id.to_s)%> + <%= link_to "Make a new EIR request", new_request_to_body_url(:url_name => @public_body.url_name)%> <% else %> - <%= link_to "Make a new FOI request", new_request_to_body_url(:public_body_id => @public_body.id.to_s)%> + <%= link_to "Make a new FOI request", new_request_to_body_url(:url_name => @public_body.url_name)%> <% end %> to <%= h(@public_body.name) %> </strong> diff --git a/app/views/request/_followup.rhtml b/app/views/request/_followup.rhtml index b375befd1..ae6dd6f98 100644 --- a/app/views/request/_followup.rhtml +++ b/app/views/request/_followup.rhtml @@ -30,7 +30,7 @@ <p>Please <strong>only</strong> write messages directly relating to your request '<%= request_link(@info_request) %>'. If you would like to ask for information that was not in your original request, then - <%= link_to "file a new request", new_request_to_body_url(:public_body_id => @info_request.public_body.id.to_s) %>. + <%= link_to "file a new request", new_request_to_body_url(:url_name => @info_request.public_body.url_name) %>. </p> <% status = @info_request.calculate_status %> diff --git a/config/routes.rb b/config/routes.rb index d18bbb833..e4d6132a9 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -34,7 +34,7 @@ ActionController::Routing::Routes.draw do |map| request.request_list '/list/:view', :action => 'list', :view => nil request.new_request '/new', :action => 'new' - request.new_request_to_body '/new/:public_body_id', :action => 'new' + request.new_request_to_body '/new/:url_name', :action => 'new' request.show_request '/request/:url_title', :action => 'show' request.details_request '/details/request/:url_title', :action => 'details' @@ -1,7 +1,11 @@ +new_request_to_body +request_id + Allow URL name in new request API Tag search + Next (things that will reduce admin time mainly) ==== |