aboutsummaryrefslogtreecommitdiffstats
path: root/app/controllers/request_controller.rb
diff options
context:
space:
mode:
authorRobin Houston <robin.houston@gmail.com>2012-01-31 17:40:02 +0000
committerRobin Houston <robin.houston@gmail.com>2012-01-31 17:40:02 +0000
commitc36b1b52e04213be91b461416d81ecbade4db159 (patch)
treebb1e2a12bc24faf0d98f5b2d9e37008f9ef405b2 /app/controllers/request_controller.rb
parent51670cc1cdb08c3da46670d42b29a6a4b4014d26 (diff)
Keep message text if user is rate-limited
If a user cannot make new requests because they are rate-limited, and they compose a request whilst logged out, include the text of the request in the message that explains about the rate limit so it is not lost.
Diffstat (limited to 'app/controllers/request_controller.rb')
-rw-r--r--app/controllers/request_controller.rb23
1 files changed, 19 insertions, 4 deletions
diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb
index fc1ffdd75..ccd9636d1 100644
--- a/app/controllers/request_controller.rb
+++ b/app/controllers/request_controller.rb
@@ -207,18 +207,28 @@ class RequestController < ApplicationController
end
# Banned from making new requests?
+ user_exceeded_limit = false
if !authenticated_user.nil? && !authenticated_user.can_file_requests?
- if authenticated_user.exceeded_limit?
- render :template => 'user/rate_limited'
- else
+ # If the reason the user cannot make new requests is that they are
+ # rate-limited, it’s possible they composed a request before they
+ # logged in and we want to include the text of the request so they
+ # can squirrel it away for tomorrow, so we detect this later after
+ # we have constructed the InfoRequest.
+ user_exceeded_limit = authenticated_user.exceeded_limit?
+ if !user_exceeded_limit
@details = authenticated_user.can_fail_html
render :template => 'user/banned'
+ return
end
- return
end
# First time we get to the page, just display it
if params[:submitted_new_request].nil? || params[:reedit]
+ if user_exceeded_limit
+ render :template => 'user/rate_limited'
+ return
+ end
+
params[:info_request] = { } if !params[:info_request]
# Read parameters in - first the public body (by URL name or id)
@@ -318,6 +328,11 @@ class RequestController < ApplicationController
return
end
+ if user_exceeded_limit
+ render :template => 'user/rate_limited'
+ return
+ end
+
if !authenticated?(
:web => _("To send your FOI request"),
:email => _("Then your FOI request to {{public_body_name}} will be sent.",:public_body_name=>@info_request.public_body.name),