diff options
-rw-r--r-- | app/controllers/request_controller.rb | 17 | ||||
-rw-r--r-- | app/views/request/new.rhtml | 2 | ||||
-rw-r--r-- | config/routes.rb | 3 | ||||
-rw-r--r-- | spec/controllers/request_controller_spec.rb | 8 | ||||
-rw-r--r-- | todo.txt | 2 |
5 files changed, 17 insertions, 15 deletions
diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb index bc03fd539..26318ef7d 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.27 2008-01-04 10:56:22 francis Exp $ +# $Id: request_controller.rb,v 1.28 2008-01-04 15:12:32 francis Exp $ class RequestController < ApplicationController @@ -23,15 +23,16 @@ class RequestController < ApplicationController def frontpage end - # Form for creating new request + # Page new form posts to def new - # Read parameters in - public body can be passed from front page - @info_request = InfoRequest.new(params[:info_request]) - @outgoing_message = OutgoingMessage.new(params[:outgoing_message]) - end + if params[:info_request].nil? || params[:outgoing_message].nil? + # Read parameters in - public body can be passed from front page + @info_request = InfoRequest.new(params[:info_request]) + @outgoing_message = OutgoingMessage.new(params[:outgoing_message]) + render :action => 'new' + return + end - # Page new form posts to - def create # See if the exact same request has already been submitted # XXX this *should* also check outgoing message joined to is an initial request (rather than follow up) # XXX this check could go in the model, except we really want to pass @existing_request to the view so it can link to it. diff --git a/app/views/request/new.rhtml b/app/views/request/new.rhtml index 8621fdf9e..b14e40f1d 100644 --- a/app/views/request/new.rhtml +++ b/app/views/request/new.rhtml @@ -13,7 +13,7 @@ <%= foi_error_messages_for :info_request, :outgoing_message %> -<% form_for(:info_request, @info_request, :url => { :action => :create }, :html => { :id => 'writeForm' } ) do |f| %> +<% form_for(:info_request, @info_request, :html => { :id => 'writeForm' } ) do |f| %> <label class="form_label" for="heading"> </label> <h1>New public Freedom of Information request</h1> diff --git a/config/routes.rb b/config/routes.rb index cbb1ca40d..020e452a2 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.25 2007-12-17 00:34:56 francis Exp $ +# $Id: routes.rb,v 1.26 2008-01-04 15:12:33 francis Exp $ ActionController::Routing::Routes.draw do |map| # The priority is based upon order of creation: first created -> highest priority. @@ -17,7 +17,6 @@ ActionController::Routing::Routes.draw do |map| request.home '/', :action => 'frontpage' request.request_list '/list', :action => 'list' request.new_request '/new', :action => 'new' - request.create_request '/create', :action => 'create' request.show_request '/request/:id', :action => 'show' request.classify_request '/classify/:incoming_message_id', :action => 'classify' end diff --git a/spec/controllers/request_controller_spec.rb b/spec/controllers/request_controller_spec.rb index 7dde21ba5..a6668c7e1 100644 --- a/spec/controllers/request_controller_spec.rb +++ b/spec/controllers/request_controller_spec.rb @@ -101,7 +101,7 @@ describe RequestController, "when creating a new request" do end it "should give an error and render 'new' template when a summary isn't given" do - post :create, :info_request => { :public_body_id => public_bodies(:geraldine_public_body).id + post :new, :info_request => { :public_body_id => public_bodies(:geraldine_public_body).id }, :outgoing_message => { :body => "This is a silly letter. It is too short to be interesting." } response.should render_template('new') @@ -112,7 +112,7 @@ describe RequestController, "when creating a new request" do :title => "Why is your quango called Geraldine?"}, :outgoing_message => { :body => "This is a silly letter. It is too short to be interesting." } } - post :create, params + post :new, params # XXX yeuch - no other easy way of getting the token so we can check # the redirect URL, as it is by definition opaque to the controller # apart from in the place that it redirects to. @@ -125,7 +125,7 @@ describe RequestController, "when creating a new request" do it "should create the request and outgoing message and redirect to request page when input is good and somebody is logged in" do session[:user_id] = users(:bob_smith_user).id - post :create, :info_request => { :public_body_id => public_bodies(:geraldine_public_body).id, + post :new, :info_request => { :public_body_id => public_bodies(:geraldine_public_body).id, :title => "Why is your quango called Geraldine?"}, :outgoing_message => { :body => "This is a silly letter. It is too short to be interesting." } ir_array = InfoRequest.find(:all, :conditions => ["title = ?", "Why is your quango called Geraldine?"]) @@ -138,7 +138,7 @@ describe RequestController, "when creating a new request" do end it "should give an error if the same request is submitted twice" do - post :create, :info_request => { :public_body_id => info_requests(:fancy_dog_request).public_body_id, + post :new, :info_request => { :public_body_id => info_requests(:fancy_dog_request).public_body_id, :title => info_requests(:fancy_dog_request).title}, :outgoing_message => { :body => info_requests(:fancy_dog_request).outgoing_messages[0].body} response.should render_template('new') @@ -79,6 +79,8 @@ Check act to see if can use pseudonym for FOI request? Later ===== +Change to Rails 2, may as well do it now rather than later. + Show public body email address on their public page, with a link to say "this isn't right!" Email me updates on this request |