aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/controllers/request_controller.rb11
-rw-r--r--app/models/info_request.rb11
2 files changed, 15 insertions, 7 deletions
diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb
index 4e40f0e7f..be193cc2d 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.46 2008-02-07 15:11:16 francis Exp $
+# $Id: request_controller.rb,v 1.47 2008-02-13 09:32:55 francis Exp $
class RequestController < ApplicationController
@@ -41,11 +41,10 @@ class RequestController < ApplicationController
end
# 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.
- # XXX could have a date range here, so say only check last month's worth of new requests. If somebody is making
- # repeated requests, say once a quarter for time information, then might need to do that.
- @existing_request = InfoRequest.find(:first, :conditions => [ 'title = ? and public_body_id = ? and outgoing_messages.body = ?', params[:info_request][:title], params[:info_request][:public_body_id], params[:outgoing_message][:body] ], :include => [ :outgoing_messages ] )
+ # XXX this check should theoretically be a validation rule in the
+ # model, except we really want to pass @existing_request to the view so
+ # it can link to it.
+ @existing_request = InfoRequest.find_by_existing_request(params[:info_request][:title], params[:info_request][:public_body_id], params[:outgoing_message][:body])
# Create both FOI request and the first request message
@info_request = InfoRequest.new(params[:info_request])
diff --git a/app/models/info_request.rb b/app/models/info_request.rb
index d5c95b8ee..8e62b04d7 100644
--- a/app/models/info_request.rb
+++ b/app/models/info_request.rb
@@ -19,7 +19,7 @@
# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved.
# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
#
-# $Id: info_request.rb,v 1.35 2008-02-06 12:20:37 francis Exp $
+# $Id: info_request.rb,v 1.36 2008-02-13 09:32:55 francis Exp $
require 'digest/sha1'
@@ -92,6 +92,15 @@ public
return self.find_by_magic_email(id, hash)
end
+ # When constructing a new request, use this to check user hasn't double submitted.
+ # XXX could have a date range here, so say only check last month's worth of new requests. If somebody is making
+ # repeated requests, say once a quarter for time information, then might need to do that.
+ # XXX this *should* also check outgoing message joined to is an initial
+ # request (rather than follow up)
+ def self.find_by_existing_request(title, public_body_id, body)
+ return InfoRequest.find(:first, :conditions => [ 'title = ? and public_body_id = ? and outgoing_messages.body = ?', title, public_body_id, body ], :include => [ :outgoing_messages ] )
+ end
+
# A new incoming email to this request
def receive(email, raw_email, is_bounce)
incoming_message = IncomingMessage.new