diff --git a/bin/gulp b/bin/gulp index c080ee6..58e2d96 100755 --- a/bin/gulp +++ b/bin/gulp @@ -1,2 +1,2 @@ #/bin/bash -exec docker-compose run --rm web gulp "$@" --debug +exec docker-compose run --rm web gulp "$@" --inspect diff --git a/private/js/modules/plugins/form.js b/private/js/modules/plugins/form.js index 78ba305..3cb3ad7 100755 --- a/private/js/modules/plugins/form.js +++ b/private/js/modules/plugins/form.js @@ -13,11 +13,14 @@ $(function() { url: $form.attr('action'), data: $form.serialize(), success: function(data) { + django_recaptcha_callbacks = []; var $new = $(data).find('#' + id); $new.find('.reveal').each(function() { $(this).removeClass('reveal reveal_animation'); }); + $new.removeClass('reveal reveal_animation'); $form.replaceWith($new); + djangoRecaptchaOnLoadCallback(); } }); }); diff --git a/requirements.in b/requirements.in index d387b1d..eba81b9 100644 --- a/requirements.in +++ b/requirements.in @@ -21,7 +21,6 @@ django-image-cropping==1.2.0 django-admin-view-permission==1.9 gunicorn==19.9.0 sentry-sdk==0.14.3 -aldryn-forms-recaptcha-plugin==1.0.0.2 django-recaptcha2==1.4.1 # compat versions django-storages<1.9 # https://stackoverflow.com/questions/60297619/divio-importerror-cannot-import-name-s3boto @@ -32,3 +31,4 @@ django-sekizai<=1.1.0 django-classy-tags<=1.0.0 djangocms-attributes-field<=1.2.0 django-haystack==2.8.1 +django-simple-captcha==0.5.12 \ No newline at end of file diff --git a/settings.py b/settings.py index 5b138a9..bed9f2f 100644 --- a/settings.py +++ b/settings.py @@ -38,8 +38,7 @@ aldryn_addons.settings.load(locals()) INSTALLED_APPS.insert(0, 'admin_view_permission') INSTALLED_APPS.extend([ - 'aldryn_forms_recaptcha_plugin', - 'snowpenguin.django.recaptcha3', + 'snowpenguin.django.recaptcha2', 'portal', 'project', 'fontawesome', @@ -261,7 +260,7 @@ if not DEBUG: DATA_UPLOAD_MAX_MEMORY_SIZE = 1024 * 1024 * 1024 -RECAPTCHA_PUBLIC_KEY = '6Lec78gZAAAAANc-oxXJPMi7BXmINlP-QkcS937g' -RECAPTCHA_PRIVATE_KEY = '6Lec78gZAAAAADuIppqW7cSh6iPw3TZQ9r-ogHtz' +RECAPTCHA_PUBLIC_KEY = '6LeILd0ZAAAAAB9xO_y8kS292wv2ikl0M8s7zFn9' +RECAPTCHA_PRIVATE_KEY = '6LeILd0ZAAAAAOGF1AvxdiGcXWLjr2BzHaQ8Zush' RECAPTCHA_SCORE_THRESHOLD = 0.5 diff --git a/src/project/cms_plugins.py b/src/project/cms_plugins.py index 5972fd7..a6b18d8 100644 --- a/src/project/cms_plugins.py +++ b/src/project/cms_plugins.py @@ -8,6 +8,9 @@ from djangocms_picture.cms_plugins import PicturePlugin as _PicturePlugin from djangocms_text_ckeditor.cms_plugins import TextPlugin as _TextPlugin from django.contrib import admin from mailchimp3 import MailChimp +from aldryn_forms.cms_plugins import Field +from snowpenguin.django.recaptcha2.fields import ReCaptchaField +from snowpenguin.django.recaptcha2.widgets import ReCaptchaWidget from project.forms import NewsletterSubscriptionForm from project.models import Section, Quote, SliderItem, SectionText, Video, DownloadSection, DownloadSectionFolder, \ @@ -206,6 +209,24 @@ class FormPlugin(_FormPlugin): 'SubmitButton', 'ReCaptchaFieldPlugin'] +@plugin_pool.register_plugin +class ReCaptchaFieldPlugin(Field): + name = 'ReCaptcha Field' + render_template = True + allow_children = False + form_field = ReCaptchaField + form_field_widget = ReCaptchaWidget + + form_field_enabled_options = [ + 'error_messages', + ] + fieldset_general_fields = [] + fieldset_advanced_fields = [] + + def get_form_field_widget_kwargs(self, instance): + return {'explicit': True} + + class SocialMediaListItemInlineAdmin(admin.TabularInline): model = SocialMediaListItem extra = 0 diff --git a/src/project/templates/main.html b/src/project/templates/main.html index b232884..9b32cde 100644 --- a/src/project/templates/main.html +++ b/src/project/templates/main.html @@ -1,4 +1,4 @@ -{% load static i18n cms_tags sekizai_tags fontawesome menu_tags %} +{% load static i18n cms_tags sekizai_tags fontawesome menu_tags recaptcha2 %}
@@ -10,6 +10,8 @@ + {% recaptcha_explicit_support %} + {% block extra_meta %} @@ -233,5 +235,7 @@ }); }); + + {% recaptcha_explicit_init LANGUAGE_CODE %}