diff --git a/examples/simple/settings/bootstrap3_theme_recaptcha.py b/examples/simple/settings/bootstrap3_theme_recaptcha.py index 57d0de82..a5d78112 100644 --- a/examples/simple/settings/bootstrap3_theme_recaptcha.py +++ b/examples/simple/settings/bootstrap3_theme_recaptcha.py @@ -2,15 +2,19 @@ from .base import * INSTALLED_APPS = list(INSTALLED_APPS) -try: +if not 'captcha' in INSTALLED_APPS: INSTALLED_APPS.append('captcha') + +if not 'fobi.contrib.plugins.form_elements.security.recaptcha' \ + in INSTALLED_APPS: INSTALLED_APPS.append( 'fobi.contrib.plugins.form_elements.security.recaptcha' ) -except Exception as err: - pass -# RECAPTCHA_PUBLIC_KEY = '' -# RECAPTCHA_PRIVATE_KEY = '' +# Test keys are taken from official dedicated Google page +# https://developers.google.com/recaptcha/docs/faq +RECAPTCHA_PUBLIC_KEY = '6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI' +RECAPTCHA_PRIVATE_KEY = '6LeIxAcTAAAAAGG-vFI1TnRWxMZNFuojJ4WifJWe' RECAPTCHA_USE_SSL = True +SILENCED_SYSTEM_CHECKS = ['captcha.recaptcha_test_key_error'] # FOBI_DEFAULT_THEME = 'simple' diff --git a/src/fobi/contrib/plugins/form_elements/security/recaptcha/base.py b/src/fobi/contrib/plugins/form_elements/security/recaptcha/base.py index 85a8d069..258f2e6d 100644 --- a/src/fobi/contrib/plugins/form_elements/security/recaptcha/base.py +++ b/src/fobi/contrib/plugins/form_elements/security/recaptcha/base.py @@ -21,7 +21,7 @@ DJANGO_SIMPLE_CAPTCHA_INSTALLED = False try: from captcha.fields import ReCaptchaField - from captcha.widgets import ReCaptcha as ReCaptchaWidget + from captcha.widgets import ReCaptchaV2Checkbox as ReCaptchaWidget DJANGO_RECAPTCHA_INSTALLED = True except ImportError as e: @@ -98,10 +98,7 @@ class ReCaptchaInputPlugin(FormElementPlugin): 'help_text': self.data.help_text, # 'initial': self.data.initial, 'required': self.data.required, - 'widget': ReCaptchaWidget( - public_key=settings.RECAPTCHA_PUBLIC_KEY, - attrs=widget_attrs - ), + 'widget': ReCaptchaWidget(attrs=widget_attrs), } return [(self.data.name, ReCaptchaField, field_kwargs)]