From d726bc0ae190c82087c45b50ddfb3fb2ca36c7d7 Mon Sep 17 00:00:00 2001 From: Greg Date: Mon, 11 May 2020 15:30:40 -0400 Subject: [PATCH 01/11] Attempted fix for bug without post URL --- cmsplugin_remote_form/cms_plugins.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cmsplugin_remote_form/cms_plugins.py b/cmsplugin_remote_form/cms_plugins.py index e08b5de..9b6f9e7 100755 --- a/cmsplugin_remote_form/cms_plugins.py +++ b/cmsplugin_remote_form/cms_plugins.py @@ -62,7 +62,10 @@ def render(self, context, instance, placeholder): self.request = request self.saved_record = self.submitted_form.save_record(instance, ts) self.notification_emails(instance) - self.remote_response = self.post_to_remote(instance, request, self.submitted_form.cleaned_data) + + if self.instance.post_url is not None: + self.remote_response = self.post_to_remote(instance, request, self.submitted_form.cleaned_data) + self.handle_response() else: form = self.submitted_form From 94edde8f535904e5ef7cdd157b550461df013ad7 Mon Sep 17 00:00:00 2001 From: Greg Date: Tue, 12 May 2020 10:21:38 -0400 Subject: [PATCH 02/11] Attempt to fix lack of POST endpoint --- cmsplugin_remote_form/cms_plugins.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cmsplugin_remote_form/cms_plugins.py b/cmsplugin_remote_form/cms_plugins.py index 9b6f9e7..25b320f 100755 --- a/cmsplugin_remote_form/cms_plugins.py +++ b/cmsplugin_remote_form/cms_plugins.py @@ -63,10 +63,10 @@ def render(self, context, instance, placeholder): self.saved_record = self.submitted_form.save_record(instance, ts) self.notification_emails(instance) - if self.instance.post_url is not None: + if self.instance.post_url: self.remote_response = self.post_to_remote(instance, request, self.submitted_form.cleaned_data) - - self.handle_response() + + self.handle_response() else: form = self.submitted_form context.update({ From 8d320b0883b8f9eebd21e7e1bc3d704ec2e85789 Mon Sep 17 00:00:00 2001 From: Greg Date: Wed, 13 May 2020 10:36:09 -0400 Subject: [PATCH 03/11] Added success callback wheee --- cmsplugin_remote_form/cms_plugins.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cmsplugin_remote_form/cms_plugins.py b/cmsplugin_remote_form/cms_plugins.py index 25b320f..e6c8ade 100755 --- a/cmsplugin_remote_form/cms_plugins.py +++ b/cmsplugin_remote_form/cms_plugins.py @@ -65,8 +65,11 @@ def render(self, context, instance, placeholder): if self.instance.post_url: self.remote_response = self.post_to_remote(instance, request, self.submitted_form.cleaned_data) - + self.handle_response() + + else: + self.success_callback() else: form = self.submitted_form context.update({ From ed188fc4a661040e515d316ce0d45bdd9a809eec Mon Sep 17 00:00:00 2001 From: Greg Date: Thu, 14 May 2020 11:50:35 -0400 Subject: [PATCH 04/11] Removed ugettext prefix from RemoteForm model --- cmsplugin_remote_form/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmsplugin_remote_form/models.py b/cmsplugin_remote_form/models.py index 4c3e4d3..3511898 100755 --- a/cmsplugin_remote_form/models.py +++ b/cmsplugin_remote_form/models.py @@ -89,7 +89,7 @@ def __str__(self): if self.post_url: url_obj = urlparse(self.post_url) return "Remote Form: %s - %s" % (url_obj.netloc, url_obj.path) - return _("Remote Form") + return "Remote Form" def recaptcha_installed(): From 2d5424a341f79ca9e2b7396e5eb9be2d8fca1cb1 Mon Sep 17 00:00:00 2001 From: Greg Date: Mon, 18 May 2020 14:33:03 -0400 Subject: [PATCH 05/11] Incremented version number --- cmsplugin_remote_form/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmsplugin_remote_form/__init__.py b/cmsplugin_remote_form/__init__.py index a85806d..19a3e5a 100755 --- a/cmsplugin_remote_form/__init__.py +++ b/cmsplugin_remote_form/__init__.py @@ -1 +1 @@ -__version__ = "1.2b7" +__version__ = "1.2b8" From 5b9529b516435cac96f1ccdd30395b9ab67e1279 Mon Sep 17 00:00:00 2001 From: Gregory Warner <64416037+worthwhile-gwarner@users.noreply.github.com> Date: Fri, 26 Jun 2020 10:52:59 -0400 Subject: [PATCH 06/11] Updated model import for Django 3 --- cmsplugin_remote_form/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmsplugin_remote_form/models.py b/cmsplugin_remote_form/models.py index 3511898..4fef62f 100755 --- a/cmsplugin_remote_form/models.py +++ b/cmsplugin_remote_form/models.py @@ -6,7 +6,7 @@ from django.db import models from django.utils.translation import ugettext_lazy as _ from django.contrib.sites.models import Site -from django.utils.encoding import python_2_unicode_compatible +from six import python_2_unicode_compatible from django.db.models import Model from cms.models.fields import PageField From 7197bda62ee7545abfe8adc9e01c5534bb1d1cb9 Mon Sep 17 00:00:00 2001 From: Gregory Warner <64416037+worthwhile-gwarner@users.noreply.github.com> Date: Fri, 26 Jun 2020 12:01:13 -0400 Subject: [PATCH 07/11] Removed SimpleMathCaptcha in favor standard Captcha --- cmsplugin_remote_form/forms.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/cmsplugin_remote_form/forms.py b/cmsplugin_remote_form/forms.py index 0ea638d..14b5bcd 100755 --- a/cmsplugin_remote_form/forms.py +++ b/cmsplugin_remote_form/forms.py @@ -4,7 +4,6 @@ from django.contrib.sites.models import Site from django.utils.translation import ugettext_lazy as _ from localflavor.us.forms import USStateSelect -from simplemathcaptcha.fields import MathCaptchaField from cmsplugin_remote_form.models import ContactRecord, RemoteForm as RemoteFormModel from cmsplugin_remote_form.utils import get_validators @@ -85,10 +84,6 @@ def __init__(self, contactFormInstance, request, *args, **kwargs): widget=forms.HiddenInput, required=False, ) - elif extraField.fieldType == "MathCaptcha": - self.extra_field_factory( - extraField, MathCaptchaField, required=True - ) elif extraField.fieldType == "ReCaptcha": self.extra_field_factory( extraField, ReCaptchaField, label="", required=True @@ -128,7 +123,7 @@ def save_record(self, instance, ts): order = RemoteFormModel.objects.get(id=instance.id).extrafield_set.order_by( "inline_ordering_position" ) - excluded_field_types = ["MathCaptcha", "ReCaptcha"] + excluded_field_types = ["ReCaptcha"] order = [ field for field in order if field.fieldType not in excluded_field_types ] From b2663921fd0a085ab4239c08dd509b01940f6d51 Mon Sep 17 00:00:00 2001 From: Gregory Warner <64416037+worthwhile-gwarner@users.noreply.github.com> Date: Fri, 26 Jun 2020 12:02:04 -0400 Subject: [PATCH 08/11] Removed Math captcha option --- cmsplugin_remote_form/models.py | 1 - 1 file changed, 1 deletion(-) diff --git a/cmsplugin_remote_form/models.py b/cmsplugin_remote_form/models.py index 4fef62f..bf234ff 100755 --- a/cmsplugin_remote_form/models.py +++ b/cmsplugin_remote_form/models.py @@ -107,7 +107,6 @@ def recaptcha_installed(): ('ImageField', 'ImageField'), ('USStateSelect', 'US State Selector'), ('IPAddressField', 'IPAddressField'), - ('MathCaptcha', 'Math Captcha'), ('auto_Textarea', _('CharField as Textarea')), ('auto_hidden_input', _('CharField as HiddenInput')), ('auto_referral_page', _('Referral page as HiddenInput')), From 2406bcc155c65c2c5d5b256a910d7f9677c14861 Mon Sep 17 00:00:00 2001 From: Gregory Warner <64416037+worthwhile-gwarner@users.noreply.github.com> Date: Fri, 26 Jun 2020 12:03:31 -0400 Subject: [PATCH 09/11] Removed django-simple-math-captcha --- requirements.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/requirements.txt b/requirements.txt index 38c0b58..1847444 100755 --- a/requirements.txt +++ b/requirements.txt @@ -1,10 +1,9 @@ django-cms django-admin-sortable -django-simple-math-captcha jsonfield django-localflavor six django-bootstrap3>=12.0.0 requests django-recaptcha>=1.4.0 -grequests \ No newline at end of file +grequests From daa4c7495d553f9ae0c93964ebcd85849dd07bf8 Mon Sep 17 00:00:00 2001 From: Greg Date: Mon, 31 Aug 2020 15:41:51 -0400 Subject: [PATCH 10/11] Attempted fix for cmsplugin --- cmsplugin_remote_form/cms_plugins.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/cmsplugin_remote_form/cms_plugins.py b/cmsplugin_remote_form/cms_plugins.py index e6c8ade..15d2565 100755 --- a/cmsplugin_remote_form/cms_plugins.py +++ b/cmsplugin_remote_form/cms_plugins.py @@ -122,8 +122,13 @@ def error_notifications_emails(self): def notification_emails(self, instance): if self.instance.notification_emails: - url = instance.page.get_public_url() - title = str(instance.page) + if instance.page: + url = instance.page.get_public_url() + title = str(instance.page) + else: + # if being rendered from modal or context without page instance + url = self.request.build_absolute_uri() + title = "Form Submission" email_addresses = [x.strip() for x in self.instance.notification_emails.split(',')] data = self.saved_record.get_ordered_data() From 7f89e89381e8c5332d89588b1809c87dfc804803 Mon Sep 17 00:00:00 2001 From: Greg Date: Thu, 8 Apr 2021 18:39:20 -0400 Subject: [PATCH 11/11] Fix for redirect page without query param and defaulting recaptcha to v3 --- cmsplugin_remote_form/forms.py | 7 ++++++- .../templates/cmsplugin_remote_form/.base.html | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/cmsplugin_remote_form/forms.py b/cmsplugin_remote_form/forms.py index 14b5bcd..d9b04b8 100755 --- a/cmsplugin_remote_form/forms.py +++ b/cmsplugin_remote_form/forms.py @@ -1,4 +1,5 @@ from captcha.fields import ReCaptchaField +from captcha.widgets import ReCaptchaV3 from django import forms from django.conf import settings from django.contrib.sites.models import Site @@ -86,7 +87,11 @@ def __init__(self, contactFormInstance, request, *args, **kwargs): ) elif extraField.fieldType == "ReCaptcha": self.extra_field_factory( - extraField, ReCaptchaField, label="", required=True + extraField, + ReCaptchaField, + widget=ReCaptchaV3, + label="", + required=True ) elif extraField.fieldType == "auto_GET_parameter": lInitial = _("Key/value parameter not available.") diff --git a/cmsplugin_remote_form/templates/cmsplugin_remote_form/.base.html b/cmsplugin_remote_form/templates/cmsplugin_remote_form/.base.html index 8d09dea..274f577 100644 --- a/cmsplugin_remote_form/templates/cmsplugin_remote_form/.base.html +++ b/cmsplugin_remote_form/templates/cmsplugin_remote_form/.base.html @@ -62,7 +62,7 @@ {% if show_thanks and object.thanks_page %} {% addtoblock 'js-external' %} {% endaddtoblock %} {% endif %}