From dc6f5dcc5be6b06739fe634e0820366d46db14fc Mon Sep 17 00:00:00 2001 From: "app@dynamicweb-production" Date: Thu, 16 Nov 2023 19:12:59 +0100 Subject: [PATCH] add recaptcha coe --- dynamicweb/settings/base.py | 3 +++ utils/forms.py | 3 +++ 2 files changed, 6 insertions(+) diff --git a/dynamicweb/settings/base.py b/dynamicweb/settings/base.py index 62fe2897..308c9029 100644 --- a/dynamicweb/settings/base.py +++ b/dynamicweb/settings/base.py @@ -56,6 +56,9 @@ dotenv.load_dotenv("{0}/.env".format(PROJECT_DIR)) from multisite import SiteID +RECAPTCHA_PUBLIC_KEY = env('RECAPTCHA_PUBLIC_KEY') +RECAPTCHA_PRIVATE_KEY = env('RECAPTCHA_PRIVATE_KEY') + UNGLEICH_BLOG_SITE_ID = int_env("UNGLEICH_BLOG_SITE_ID") SITE_ID = SiteID(default=(UNGLEICH_BLOG_SITE_ID if UNGLEICH_BLOG_SITE_ID > 0 else 1)) diff --git a/utils/forms.py b/utils/forms.py index f35c90f4..92b442af 100644 --- a/utils/forms.py +++ b/utils/forms.py @@ -4,6 +4,8 @@ from django.core.mail import EmailMultiAlternatives from django.template.loader import render_to_string from django.utils.translation import ugettext_lazy as _ +from captcha.fields import ReCaptchaField + from membership.models import CustomUser from .models import ContactMessage, BillingAddress, UserBillingAddress @@ -188,6 +190,7 @@ class UserBillingAddressForm(forms.ModelForm): class ContactUsForm(forms.ModelForm): error_css_class = 'autofocus' + captcha = ReCaptchaField() class Meta: model = ContactMessage