Skip to content

Commit

Permalink
Add setting to skip recaptcha checks in debug mode
Browse files Browse the repository at this point in the history
This is useful for unit testing
  • Loading branch information
ntucker committed Nov 18, 2015
1 parent afaf515 commit 0af52b2
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions recaptcha_form/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@
import recaptcha.client.captcha as captcha


# Do you want to bypass reCAPTCHA validation while in DEBUG mode?
SKIP_IF_IN_DEBUG_MODE = False


### ERROR_CODES
ERROR_CODES = {
"unknown" : _("Unknown error."),
Expand Down Expand Up @@ -51,7 +47,10 @@ def __init__(self, remote_ip, *args, **kwargs):
super(RecaptchaField, self).__init__(*args, **kwargs)

def clean(self, value):
if SKIP_IF_IN_DEBUG_MODE and settings.DEBUG:
if getattr(settings, 'RECAPTCHA_SKIP', False) or (
getattr(settings, 'RECAPTCHA_SKIP_IF_IN_DEBUG_MODE', False)
and settings.DEBUG
):
return True
value = super(RecaptchaField, self).clean(value)
challenge, response = value
Expand Down

0 comments on commit 0af52b2

Please sign in to comment.