Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
The Tor Project
TPA
Anonymous Ticket Portal
Commits
f183aff8
Commit
f183aff8
authored
Feb 11, 2021
by
ViolanteCodes
Browse files
added template render with 403 status code for exception.isRateLimited
parent
c60cb76d
Changes
1
Hide whitespace changes
Inline
Side-by-side
ticketlobby/urls.py
View file @
f183aff8
...
...
@@ -17,16 +17,15 @@ from django.contrib import admin
from
django.urls
import
path
,
include
from
ratelimit.exceptions
import
Ratelimited
from
django.http
import
HttpResponse
from
django.shortcuts
import
redirect
from
django.shortcuts
import
redirect
,
render
def
handler403
(
request
,
exception
=
None
):
"""Custom 403 handler for ratelimit exceptions."""
response_message
=
"""This ticket has failed due to too many requests in
a short period of time. If you like, you can hit the "back" button to return
to your form. Your data should still be filled in. You can then
wait and retry creating your ticket."""
if
isinstance
(
exception
,
Ratelimited
):
return
HttpResponse
(
response_message
,
status
=
403
)
return
render
(
request
,
template_name
=
'anonticket/rate_limited.html'
,
status
=
403
)
return
HttpResponseForbidden
(
'Forbidden'
)
urlpatterns
=
[
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment