diff --git a/gobotany/plantshare/backends/default/forms.py b/gobotany/plantshare/backends/default/forms.py index 0de798c5c..e21d075db 100644 --- a/gobotany/plantshare/backends/default/forms.py +++ b/gobotany/plantshare/backends/default/forms.py @@ -1,6 +1,6 @@ -from captcha.fields import ReCaptchaField from registration.forms import RegistrationForm - +from snowpenguin.django.recaptcha2.fields import ReCaptchaField +from snowpenguin.django.recaptcha2.widgets import ReCaptchaWidget class RegistrationFormWithCaptcha(RegistrationForm): - captcha = ReCaptchaField(attrs={'theme': 'clean'}) + captcha = ReCaptchaField(widget=ReCaptchaWidget()) \ No newline at end of file diff --git a/gobotany/settings.py b/gobotany/settings.py index 8e034ae58..73fa1da2f 100644 --- a/gobotany/settings.py +++ b/gobotany/settings.py @@ -169,6 +169,7 @@ 'haystack', 'haystack_panel', 'imagekit', + 'snowpenguin.django.recaptcha2', 'tinymce', 'registration', #'emailconfirmation', # Temporarily uncomment to create this app's @@ -263,12 +264,14 @@ EMAIL_CONFIRMATION_DAYS = 3 # For django-recaptcha -if DEV_FEATURES: - RECAPTCHA_PUBLIC_KEY = os.environ.get('RECAPTCHA_PUBLIC_KEY_DEV', '') - RECAPTCHA_PRIVATE_KEY = os.environ.get('RECAPTCHA_PRIVATE_KEY_DEV', '') -else: +if IN_PRODUCTION: # Dev, Prod instances on Heroku + # Note: _DEV keys were generated to include Heroku Dev, so Dev may fail. + # TODO: may need to re-generate again: 1. Heroku (Prod, Dev), 2. Local RECAPTCHA_PUBLIC_KEY = os.environ.get('RECAPTCHA_PUBLIC_KEY', '') RECAPTCHA_PRIVATE_KEY = os.environ.get('RECAPTCHA_PRIVATE_KEY', '') +else: # local development + RECAPTCHA_PUBLIC_KEY = os.environ.get('RECAPTCHA_PUBLIC_KEY_DEV', '') + RECAPTCHA_PRIVATE_KEY = os.environ.get('RECAPTCHA_PRIVATE_KEY_DEV', '') RECAPTCHA_USE_SSL = True # For static Google Maps (dynamic ones use a different key, in google_maps.js) diff --git a/gobotany/site/templates/gobotany/_base.html b/gobotany/site/templates/gobotany/_base.html index 82238e6cd..fd3d4065e 100644 --- a/gobotany/site/templates/gobotany/_base.html +++ b/gobotany/site/templates/gobotany/_base.html @@ -1,4 +1,5 @@ {% load gobotany_tags %} +{% load recaptcha2 %} @@ -50,6 +51,8 @@ {% include "gobotany/_google_analytics.html" %} {% endif %} + {% recaptcha_init %} + {% block ember_templates %}{% endblock %} diff --git a/setup.py b/setup.py index 4fd60e4e7..fa225eb61 100644 --- a/setup.py +++ b/setup.py @@ -33,7 +33,7 @@ # Login and registration 'django-email-confirmation==0.2', - 'django-recaptcha==1.0.5', + 'django-recaptcha2==1.0.3', 'django-registration==2.1.1', # For storing images on S3.