Permalink
Browse files

redirect page setting option

  • Loading branch information...
1 parent 4255e9d commit f870375a753c0383426e5076df559122a3e0bbd9 @pdr committed Aug 12, 2011
Showing with 8 additions and 3 deletions.
  1. +7 −2 honeypot/decorators.py
  2. +1 −1 honeypot/templates/honeypot/honeypot_error.html
View
@@ -5,7 +5,7 @@
from django.conf import settings
from django.utils.safestring import mark_safe
-from django.http import HttpResponseBadRequest, HttpResponse
+from django.http import HttpResponseBadRequest, HttpResponseRedirect
from django.template.loader import render_to_string
def honeypot_equals(val):
@@ -26,11 +26,16 @@ def verify_honeypot_value(request, field_name):
HONEYPOT_VERIFIER.
"""
verifier = getattr(settings, 'HONEYPOT_VERIFIER', honeypot_equals)
+ redirect = getattr(settings, 'HONEYPOT_REDIRECT_URL', None)
if request.method == 'POST':
field = field_name or settings.HONEYPOT_FIELD_NAME
if field not in request.POST or not verifier(request.POST[field]):
+ #If a redirect url is specified in the settings, redirect user
+ if redirect != None:
+ return HttpResponseRedirect(redirect)
+
resp = render_to_string('honeypot/honeypot_error.html',
- {'fieldname': field})
+ {'fieldname': field})
return HttpResponseBadRequest(resp)
def check_honeypot(func=None, field_name=None):
@@ -1,3 +1,3 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
- <body><h1>Thanks for registering!</h1><p>Your account has been created.</p></body>
+ <body><h1>400 Bad Request</h1><p>Honey Pot Error ({{fieldname}}). Request aborted.</p></body>
</html>

0 comments on commit f870375

Please sign in to comment.