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" diff --git a/cmsplugin_remote_form/cms_plugins.py b/cmsplugin_remote_form/cms_plugins.py index e08b5de..15d2565 100755 --- a/cmsplugin_remote_form/cms_plugins.py +++ b/cmsplugin_remote_form/cms_plugins.py @@ -62,8 +62,14 @@ 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) - self.handle_response() + + 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({ @@ -116,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() diff --git a/cmsplugin_remote_form/forms.py b/cmsplugin_remote_form/forms.py index 0ea638d..d9b04b8 100755 --- a/cmsplugin_remote_form/forms.py +++ b/cmsplugin_remote_form/forms.py @@ -1,10 +1,10 @@ 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 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,13 +85,13 @@ 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 + extraField, + ReCaptchaField, + widget=ReCaptchaV3, + label="", + required=True ) elif extraField.fieldType == "auto_GET_parameter": lInitial = _("Key/value parameter not available.") @@ -128,7 +128,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 ] diff --git a/cmsplugin_remote_form/models.py b/cmsplugin_remote_form/models.py index 4c3e4d3..bf234ff 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 @@ -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(): @@ -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')), 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 %} 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