aboutsummaryrefslogtreecommitdiffstats
path: root/app/controllers/request_controller.rb
diff options
context:
space:
mode:
authorLouise Crow <louise.crow@gmail.com>2013-10-24 17:03:52 +0100
committerLouise Crow <louise.crow@gmail.com>2013-12-04 09:32:43 +0000
commitce262657761c1c47c47e2f6cc7bf683543ebbdb7 (patch)
tree800fc74aebcbc5dae39800abdf0830f2afa6251e /app/controllers/request_controller.rb
parent4b2e3ef0b6f5b881597242a4afe1404415256f3b (diff)
Add check for double submission.
Diffstat (limited to 'app/controllers/request_controller.rb')
-rw-r--r--app/controllers/request_controller.rb13
1 files changed, 8 insertions, 5 deletions
diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb
index 047fc7acf..ccf824e75 100644
--- a/app/controllers/request_controller.rb
+++ b/app/controllers/request_controller.rb
@@ -188,13 +188,9 @@ class RequestController < ApplicationController
redirect_to select_authorities_path and return
end
- # TODO: I do think we should probably check for double submission of batch
- # requests as we do in 'new' for ordinary requests with find_existing
-
# TODO: Decide if we make batch requesters describe their undescribed requests
# before being able to make a new batch request
-
if !authenticated_user.can_file_requests?
@details = authenticated_user.can_fail_html
render :template => 'user/banned' and return
@@ -205,12 +201,18 @@ class RequestController < ApplicationController
return render_new_compose(batch=true)
end
+ # Check for double submission of batch
+ @existing_batch = InfoRequestBatch.find_existing(authenticated_user,
+ params[:info_request][:title],
+ params[:outgoing_message][:body],
+ params[:public_body_ids])
+
@info_request = InfoRequest.create_from_attributes(params[:info_request],
params[:outgoing_message],
authenticated_user)
@outgoing_message = @info_request.outgoing_messages.first
@info_request.is_batch_request_template = true
- if !@info_request.valid?
+ if !@existing_batch.nil? || !@info_request.valid?
# We don't want the error "Outgoing messages is invalid", as in this
# case the list of errors will also contain a more specific error
# describing the reason it is invalid.
@@ -227,6 +229,7 @@ class RequestController < ApplicationController
# TODO: give messages about bodies
# that are no longer requestable
@info_request_batch = InfoRequestBatch.create!(:title => params[:info_request][:title],
+ :body => params[:outgoing_message][:body],
:user => authenticated_user)
@public_bodies = PublicBody.where({:id => params[:public_body_ids]}).all
@public_bodies.each do |public_body|