aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/controllers/file_request_controller.rb29
-rw-r--r--todo.txt4
2 files changed, 20 insertions, 13 deletions
diff --git a/app/controllers/file_request_controller.rb b/app/controllers/file_request_controller.rb
index 8424c83b0..b87fc4a9e 100644
--- a/app/controllers/file_request_controller.rb
+++ b/app/controllers/file_request_controller.rb
@@ -4,26 +4,33 @@
# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved.
# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
#
-# $Id: file_request_controller.rb,v 1.5 2007-09-10 18:58:43 francis Exp $
+# $Id: file_request_controller.rb,v 1.6 2007-09-11 15:21:16 francis Exp $
class FileRequestController < ApplicationController
def index
end
def create
+ # Create both FOI request and the first request message
@info_request = InfoRequest.new(params[:info_request])
- @outgoing_message = OutgoingMessage.new(params[:outgoing_message].merge({ :status => 'ready',
- :message_type => 'initial_request'}))
+ @outgoing_message = OutgoingMessage.new(params[:outgoing_message].merge({
+ :status => 'ready',
+ :message_type => 'initial_request'
+ }))
- InfoRequest.transaction do
- @info_request.save!
- @outgoing_message.info_request_id = @info_request.id
- @outgoing_message.save!
- # render create action
+ # Save both models
+ ActiveRecord::Base.transaction do
+ begin
+ @info_request.save!
+ @outgoing_message.info_request_id = @info_request.id
+ @outgoing_message.save!
+ # render create action
+ rescue ActiveRecord::RecordInvalid => e
+ @outgoing_message.valid? # force cecking of errors even if info_request fails
+ @outgoing_message.errors.full_messages.delete("info_request")
+ render :action => 'index'
+ end
end
- rescue ActiveRecord::RecordInvalid => e
- @outgoing_message.valid? # force cecking of errors even if info_request fails
- render :action => 'index'
end
end
diff --git a/todo.txt b/todo.txt
index a5bff0b3e..57400df5b 100644
--- a/todo.txt
+++ b/todo.txt
@@ -1,11 +1,11 @@
Give a better login dialog
-Check validation for saving info request / outgoing message pair works with transactions fine
Set "null" and "default" options more in schema
-Tidy up error message text (like "body must be filled in" on info request form)
+Tidy up error message text (like "body must be filled in") on info request form
Make sure that constraints / foreign keys in model are in same order as data in schema
Check have validates_presence_of for every belongs_to
Check using :string rather than :text for definitely limited fields like "status"
+IF just title is blank says "Info request must be filled in"
Redirect the front page to the new FOI request page
Make it say "dear" as default letter