diff --git a/.python-version b/.python-version new file mode 100644 index 0000000..7c69a55 --- /dev/null +++ b/.python-version @@ -0,0 +1 @@ +3.7.0 diff --git a/AUTHORS.txt b/AUTHORS.txt old mode 100644 new mode 100755 diff --git a/LICENSE b/LICENSE old mode 100644 new mode 100755 diff --git a/MANIFEST.in b/MANIFEST.in old mode 100644 new mode 100755 diff --git a/README.md b/README.md old mode 100644 new mode 100755 index a10bd06..12b909d --- a/README.md +++ b/README.md @@ -96,141 +96,7 @@ If you are not using the default template settings of Django, make sure that `` Please have a look at the latest commits for the work-in-progress development version. -### 1.3.5 - 10. 10. 2016 -- Replaced https://github.com/centralniak/django-inline-ordering dependency with https://github.com/iambrandontaylor/django-admin-sortable. - Upgrading: Remove `'inline_ordering'` from `INSTALLED_APPS `and add `'adminsortable'` instead. - -### 1.3.2 - 10. 10. 2016 -- Fixed `MANIFEST.in`. Locale files are now correctly included - -### 1.3.1 - 10. 10. 2016 -- Added a missing migration - -### 1.3.0 - 10. 10. 2016 -- Renamed plugin field `submit` to `submit_button_text` to achieve django CMS 3.3/3.4 compatibility. Please migrate your database and update your templates. - -### 1.2.7 - 29. 03. 2016 - -- French translation -- Fix setuptools compatibility issue - -### 1.2.6 - 05. 01. 2015 - -- Added a CharFieldWithValidator field that supports validators -- Use email subject defined in plugin settings -- Set `required_css_class` of contact form -- Use more specific setting `REMOTE_FORM_FROM_EMAIL`, and use `DEFAULT_FROM_EMAIL` as a fallback - -### 1.2.5 - 10. 11. 2015 - -- Handle multiple forms located on the same page. See the two relevant commits [7749d44](https://github.com/arteria/cmsplugin-contact-plus/commit/7749d44d39f1b106a1b4c980615fab7a6a810a37) and [b8793f7](https://github.com/arteria/cmsplugin-contact-plus/commit/b8793f7bc0ce573bbed1bb9ffa20f9b87191fa8b) for more info. Please modify your templates. - -### 1.2.3 - -- reCAPTCHA support - -### 1.1.14 - 20. 03. 2015 - -- Multiple file and image fields / Upload files and images, upload will be placed directly into ``MEDIA_ROOT``. - -### 1.1.13 - 17. 11. 2014 - -- Adding Spanish translation -- Support migrations for django __1.7__ and django cms __3.0.6__ - -### 1.1.12 - -- Reply-to email support -- Added ContactRecords to store Contact History in the Database. - -### 1.1.11 - -- Integration of a simple math captcha (PR #16) - -### 1.1.10 - -- Removed unordered data (cleaned_data). Now use ordered_data instead. -- Fixed typo - -### 1.1.9 - -- Fixed lower() vs. slugify() for key lookup. - -### 1.1.8 - -- Field ordering in the email is now equal to the definition. - -### 1.1.7 - -- django CMS 3.0 caching compatibility. - -### 1.1.6 - -- Bugfix, missing template info, https://github.com/arteria/cmsplugin-contact-plus/commit/1fa9236 - -### 1.1.5 - -- Trigger a signal ``contact_message_sent`` when a message was sent successfully. See signals.py . -- Multiple templates support, in your project settings define - - ``` - CMSPLUGIN_REMOTE_FORM_TEMPLATES = [ - ('cmsplugin_remote_form/contact.html', 'contact.html'), - ('cmsplugin_remote_form/hello.html', 'hello.html'), - # more templates here - ] - ``` - - To be able to use the new features, please migrate manually - - ``` ALTER TABLE `cmsplugin_contactplus` ADD `template` varchar(255) NOT NULL AFTER `submit`; ``` - -### 1.1.4 - -- Packaging was modified for PyPI. -- Upload script for PyPI. Internal note: just execute ``./upload-to-pypi.sh``. - - -### 1.1.3 -- Better readability in email. - -### 1.1.2 -- Patch version for PyPI with corrected Manifest.in, see issue #4. - -### 1.1.1 -- Added include for templates im Manifest.in, fixes issue #4. - -### 1.1.0 -- Generic Query parameter (GET key) to hidden field. Use this in attach additional hidden data to the form. The slugified label is used for key lookup in the GET parameters. Eg.: -label is 'Favorite Color', than the lookup in the URL is done based on 'favorite-color', in www.example.com?favorite-color=blue will pass {..., u'favorite-color':'blue', ...} to the email. - - -### 1.0.4 -- Fixed default "from email address" in case ``ADMINS`` is not defined in ``settings.py``. (Issue #2) -- Fixed typos and added translation markers. - -### 1.0.3 -- Improved Documentation -- Added ``auto_TextArea`` shortcut to create a TextArea. Note: Currently the widget defined in the plugins are ignored. -- Hidden "referral page" field. Reads referral from request. -- Generic Hidden fields. Use this in combination with JavaScript/jQuery to attach additional data to the form sent by email. - -For example, the field lable for the 'CharField as HiddenInput' is named to "Object description". -Using the lable name, the ID for the input field will be 'id_object-description', the name 'object-description'. - -Store data is dead easy using jQuery. - - - $('#id_object-description').val('Hello Hidden World'); // The string 'Hello Hidden World' will be send by email as well. - - - -### 1.0.2 -Fixed indentation /EOF in setup.py - - -### 1.0.1 -Fixed IndentationError in setup.py - -### 1.0.0 -[arteria](https://github.com/arteria/) open sourced cmsplugin_remote_form unter the MIT License. This plugin was built on a fork of [cmsplugin_contact](https://github.com/rtpm/cmsplugin_contact). Kudos! +### 1.2 - Unreleased +- Drop python 2 support +- Drop support for django < 2.2 + \ No newline at end of file diff --git a/cmsplugin_remote_form/__init__.py b/cmsplugin_remote_form/__init__.py index a82b376..a85806d 100755 --- a/cmsplugin_remote_form/__init__.py +++ b/cmsplugin_remote_form/__init__.py @@ -1 +1 @@ -__version__ = "1.1.1" +__version__ = "1.2b7" diff --git a/cmsplugin_remote_form/actions.py b/cmsplugin_remote_form/actions.py index 601f488..e383903 100644 --- a/cmsplugin_remote_form/actions.py +++ b/cmsplugin_remote_form/actions.py @@ -73,7 +73,7 @@ def export_as_csv(modeladmin, request, queryset): j = getattr(obj, field) for l in j: try: - for k, v in l.iteritems(): + for k, v in l.items(): lut.add_field(k) except AttributeError: pass @@ -88,7 +88,7 @@ def export_as_csv(modeladmin, request, queryset): if field in json_fields: j = getattr(obj, field) for l in j: - for k, v in l.iteritems(): + for k, v in l.items(): try: row[lut.get_idx(k)] = v.encode('utf-8') except AttributeError: diff --git a/cmsplugin_remote_form/cms_plugins.py b/cmsplugin_remote_form/cms_plugins.py index 7e7ede0..e08b5de 100755 --- a/cmsplugin_remote_form/cms_plugins.py +++ b/cmsplugin_remote_form/cms_plugins.py @@ -46,7 +46,7 @@ def render(self, context, instance, placeholder): if instance and instance.template: self.render_template = instance.template - if request.method == "POST" and "remote_form_" + str(instance.id) in request.POST.keys(): + if request.method == "POST" and "remote_form_" + str(instance.id) in list(request.POST.keys()): ts = str(int(time.time())) self.submitted_form = RemoteFormForm(contactFormInstance=instance, request=request, @@ -69,7 +69,7 @@ def render(self, context, instance, placeholder): context.update({ 'object': instance, 'form': form, - 'show_thanks': show_thanks + 'show_thanks': show_thanks, }) return context @@ -85,11 +85,11 @@ def post_to_remote(self, instance, request, cleaned_data): try: response = requests.post(instance.post_url, data=cleaned_data) return response - except requests.ConnectionError, e: - print e + except requests.ConnectionError as e: + print(e) def determine_success(self): - return "Please correct the following errors:" not in self.remote_response.content + return "Please correct the following errors:" not in self.remote_response.text def success_callback(self): pass @@ -99,7 +99,7 @@ def failure_callback(self): def error_notifications_emails(self): if self.instance.error_notification_emails: - error = self.remote_response.content if self.remote_response else "Connection Error" + error = self.remote_response.text if self.remote_response else "Connection Error" error_email_addresses = [x.strip() for x in self.instance.error_notification_emails.split(',')] message = EmailMultiAlternatives( "Form Submission Error", @@ -121,8 +121,8 @@ def notification_emails(self, instance): email_addresses = [x.strip() for x in self.instance.notification_emails.split(',')] data = self.saved_record.get_ordered_data() - content = u'\n'.join( - u"{key}: {val}".format(key=key, val=val) for (key, val) in data.items() + content = '\n'.join( + "{key}: {val}".format(key=key, val=val) for (key, val) in list(data.items()) ) diff --git a/cmsplugin_remote_form/forms.py b/cmsplugin_remote_form/forms.py index d794118..0ea638d 100755 --- a/cmsplugin_remote_form/forms.py +++ b/cmsplugin_remote_form/forms.py @@ -1,26 +1,31 @@ - - - +from captcha.fields import ReCaptchaField from django import forms -from django.template.defaultfilters import slugify -from django.contrib.sites.models import Site from django.conf import settings +from django.contrib.sites.models import Site from django.utils.translation import ugettext_lazy as _ - -from captcha.fields import ReCaptchaField +from localflavor.us.forms import USStateSelect from simplemathcaptcha.fields import MathCaptchaField -from cmsplugin_remote_form.models import RemoteForm as RemoteFormModel, ContactRecord + +from cmsplugin_remote_form.models import ContactRecord, RemoteForm as RemoteFormModel from cmsplugin_remote_form.utils import get_validators -from localflavor.us.forms import USStateSelect + class RemoteForm(forms.Form): - required_css_class = getattr(settings, 'REMOTE_FORM_REQUIRED_CSS_CLASS', 'required') + required_css_class = getattr(settings, "REMOTE_FORM_REQUIRED_CSS_CLASS", "required") + + def make_select2(self, extraField): + attrs = self.fields[extraField.name].widget.attrs + classes = attrs.get('class') + if classes and 'select2' not in classes.split(' '): + attrs['class'] += ' ' + 'select2' + elif not classes: + attrs['class'] = 'select2' def extra_field_factory(self, extraField, formsFieldClass, **kwargs): field_kwargs = { - 'label': extraField.label, - 'required': extraField.required, - 'initial': extraField.initial, + "label": extraField.label, + "required": extraField.required, + "initial": extraField.initial, } field_kwargs.update(kwargs) @@ -32,86 +37,116 @@ def extra_field_factory(self, extraField, formsFieldClass, **kwargs): def __init__(self, contactFormInstance, request, *args, **kwargs): super(RemoteForm, self).__init__(*args, **kwargs) self.object = contactFormInstance - if 'instance' not in kwargs: + if "instance" not in kwargs: for extraField in contactFormInstance.extrafield_set.all(): - if extraField.fieldType == 'CharField': + if extraField.fieldType == "CharField": self.extra_field_factory(extraField, forms.CharField) - elif extraField.fieldType == 'BooleanField': + elif extraField.fieldType == "BooleanField": self.extra_field_factory(extraField, forms.BooleanField) - elif extraField.fieldType == 'EmailField': + elif extraField.fieldType == "EmailField": self.extra_field_factory(extraField, forms.EmailField) - elif extraField.fieldType == 'DecimalField': + elif extraField.fieldType == "DecimalField": self.extra_field_factory(extraField, forms.DecimalField) - elif extraField.fieldType == 'FloatField': + elif extraField.fieldType == "FloatField": self.extra_field_factory(extraField, forms.FloatField) - elif extraField.fieldType == 'FileField': + elif extraField.fieldType == "FileField": self.extra_field_factory(extraField, forms.FileField) - elif extraField.fieldType == 'ImageField': + elif extraField.fieldType == "ImageField": self.extra_field_factory(extraField, forms.ImageField) - elif extraField.fieldType == 'IntegerField': + elif extraField.fieldType == "IntegerField": self.extra_field_factory(extraField, forms.IntegerField) - elif extraField.fieldType == 'USStateSelect': - self.extra_field_factory(extraField, forms.CharField, widget=USStateSelect) - elif extraField.fieldType == 'IPAddressField': + elif extraField.fieldType == "USStateSelect": + self.extra_field_factory( + extraField, forms.CharField, widget=USStateSelect + ) + elif extraField.fieldType == "IPAddressField": self.extra_field_factory(extraField, forms.IPAddressField) - elif extraField.fieldType == 'auto_Textarea': - self.extra_field_factory(extraField, forms.CharField, widget=forms.Textarea) - elif extraField.fieldType == 'auto_hidden_input': - self.extra_field_factory(extraField, forms.CharField, widget=forms.HiddenInput, required=False) - elif extraField.fieldType == 'auto_referral_page': + elif extraField.fieldType == "auto_Textarea": + self.extra_field_factory( + extraField, forms.CharField, widget=forms.Textarea + ) + elif extraField.fieldType == "auto_hidden_input": + self.extra_field_factory( + extraField, + forms.CharField, + widget=forms.HiddenInput, + required=False, + ) + elif extraField.fieldType == "auto_referral_page": lInitial = _("No referral available.") if request: - lInitial = request.META.get('HTTP_REFERER', _('No referral available.')) + lInitial = request.META.get( + "HTTP_REFERER", _("No referral available.") + ) self.extra_field_factory( extraField, forms.CharField, initial=lInitial, # NOTE: This overwrites extraField.initial! widget=forms.HiddenInput, - required=False) - elif extraField.fieldType == 'MathCaptcha': + required=False, + ) + elif extraField.fieldType == "MathCaptcha": self.extra_field_factory( - extraField, - MathCaptchaField, - required=True) - elif extraField.fieldType == 'ReCaptcha': + extraField, MathCaptchaField, required=True + ) + elif extraField.fieldType == "ReCaptcha": self.extra_field_factory( - extraField, - ReCaptchaField, - label='', - required=True) - elif extraField.fieldType == 'auto_GET_parameter': + extraField, ReCaptchaField, label="", required=True + ) + elif extraField.fieldType == "auto_GET_parameter": lInitial = _("Key/value parameter not available.") if request: - lInitial = request.GET.get(extraField.name, 'n/a') + lInitial = request.GET.get(extraField.name, "n/a") self.extra_field_factory( extraField, forms.CharField, initial=lInitial, widget=forms.HiddenInput, - required=False) - elif extraField.fieldType == 'CharFieldWithValidator': + required=False, + ) + elif extraField.fieldType == "CharFieldWithValidator": + self.extra_field_factory( + extraField, forms.CharField, validators=get_validators() + ) + elif extraField.fieldType == "ChoiceField": + choices = [("No Choice", "No Choices in 'initial'")] + if extraField.initial: + choices = [ + (c.strip(), c.strip()) for c in extraField.initial.split(",") + ] + self.extra_field_factory( extraField, - forms.CharField, - validators=get_validators()) + forms.ChoiceField, + choices=choices, + ) + self.make_select2(extraField) def save_record(self, instance, ts): if instance.collect_records: current_site = Site.objects.get_current() - order = RemoteFormModel.objects.get(id=instance.id).extrafield_set.order_by('inline_ordering_position') - excluded_field_types = ['MathCaptcha', 'ReCaptcha'] - order = [field for field in order if field.fieldType not in excluded_field_types] + order = RemoteFormModel.objects.get(id=instance.id).extrafield_set.order_by( + "inline_ordering_position" + ) + excluded_field_types = ["MathCaptcha", "ReCaptcha"] + order = [ + field for field in order if field.fieldType not in excluded_field_types + ] ordered_dic_list = [] for field in order: key = field.name - value = self.cleaned_data.get(key, '(no input)') + value = self.cleaned_data.get(key, "(no input)") # redefine value for files... if field.fieldType in ["FileField", "ImageField"]: - val = ts + '-' + str(value) + val = ts + "-" + str(value) if settings.MEDIA_URL.startswith("http"): value = "%s%s" % (settings.MEDIA_URL, val) else: - value = "http://%s%s%s" % (current_site, settings.MEDIA_URL, val) + value = "http://%s%s%s" % ( + current_site, + settings.MEDIA_URL, + val, + ) ordered_dic_list.append({field.label: value}) record = ContactRecord(contact_form=instance, data=ordered_dic_list) diff --git a/cmsplugin_remote_form/migrations/0001_initial.py b/cmsplugin_remote_form/migrations/0001_initial.py index 5b73678..899cfe0 100644 --- a/cmsplugin_remote_form/migrations/0001_initial.py +++ b/cmsplugin_remote_form/migrations/0001_initial.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # Generated by Django 1.9.12 on 2017-03-28 13:52 -from __future__ import unicode_literals + from django.db import migrations, models import django.db.models.deletion diff --git a/cmsplugin_remote_form/migrations/0002_auto_20170421_1127.py b/cmsplugin_remote_form/migrations/0002_auto_20170421_1127.py index 5bd60c1..179fd8b 100644 --- a/cmsplugin_remote_form/migrations/0002_auto_20170421_1127.py +++ b/cmsplugin_remote_form/migrations/0002_auto_20170421_1127.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # Generated by Django 1.10.6 on 2017-04-21 15:27 -from __future__ import unicode_literals + from django.db import migrations, models diff --git a/cmsplugin_remote_form/migrations/0003_remoteform_on_submit.py b/cmsplugin_remote_form/migrations/0003_remoteform_on_submit.py index efa63af..26330c8 100644 --- a/cmsplugin_remote_form/migrations/0003_remoteform_on_submit.py +++ b/cmsplugin_remote_form/migrations/0003_remoteform_on_submit.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # Generated by Django 1.10.7 on 2017-06-19 20:17 -from __future__ import unicode_literals + from django.db import migrations, models diff --git a/cmsplugin_remote_form/migrations/0004_remoteform_notification_emails.py b/cmsplugin_remote_form/migrations/0004_remoteform_notification_emails.py index 64ac0ef..fb817b0 100644 --- a/cmsplugin_remote_form/migrations/0004_remoteform_notification_emails.py +++ b/cmsplugin_remote_form/migrations/0004_remoteform_notification_emails.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # Generated by Django 1.10.7 on 2017-10-10 20:44 -from __future__ import unicode_literals + from django.db import migrations, models diff --git a/cmsplugin_remote_form/migrations/0005_auto_20200429_1442.py b/cmsplugin_remote_form/migrations/0005_auto_20200429_1442.py new file mode 100644 index 0000000..9bcb27a --- /dev/null +++ b/cmsplugin_remote_form/migrations/0005_auto_20200429_1442.py @@ -0,0 +1,48 @@ +# Generated by Django 2.2.12 on 2020-04-29 18:42 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('cmsplugin_remote_form', '0004_remoteform_notification_emails'), + ] + + operations = [ + migrations.AlterField( + model_name='extrafield', + name='fieldType', + field=models.CharField(choices=[('CharField', 'CharField'), ('BooleanField', 'BooleanField'), ('EmailField', 'EmailField'), ('DecimalField', 'DecimalField'), ('FloatField', 'FloatField'), ('IntegerField', 'IntegerField'), ('FileField', 'FileField'), ('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'), ('auto_GET_parameter', 'GET parameter as HiddenInput'), ('CharFieldWithValidator', 'CharFieldWithValidator'), ('ChoiceField', 'ChoiceField'), ('ReCaptcha', 'reCAPTCHA')], max_length=100), + ), + migrations.AlterField( + model_name='extrafield', + name='initial', + field=models.CharField(blank=True, max_length=4096, null=True), + ), + migrations.AlterField( + model_name='extrafield', + name='name', + field=models.CharField(default='', max_length=100, verbose_name='Name'), + ), + migrations.AlterField( + model_name='remoteform', + name='error_notification_emails', + field=models.CharField(blank=True, help_text='multiple emails separated by commas', max_length=250, null=True, verbose_name='Email Errors To:'), + ), + migrations.AlterField( + model_name='remoteform', + name='on_submit', + field=models.CharField(blank=True, help_text='Google Analytics Code', max_length=400, null=True), + ), + migrations.AlterField( + model_name='remoteform', + name='post_url', + field=models.CharField(default='#remoteURL', max_length=200, null=True, verbose_name='Remote URL'), + ), + migrations.AlterField( + model_name='remoteform', + name='template', + field=models.CharField(choices=[('cmsplugin_remote_form_templates/default.html', 'Default'), ('cmsplugin_remote_form_templates/vertical_onecol.html', 'Vertical - One Col')], default='cmsplugin_remote_form/default.html', max_length=255), + ), + ] diff --git a/cmsplugin_remote_form/migrations/0006_auto_20200504_1004.py b/cmsplugin_remote_form/migrations/0006_auto_20200504_1004.py new file mode 100644 index 0000000..c89a35c --- /dev/null +++ b/cmsplugin_remote_form/migrations/0006_auto_20200504_1004.py @@ -0,0 +1,31 @@ +# Generated by Django 2.2.12 on 2020-05-04 14:04 + +import cms.models.fields +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('cms', '0022_auto_20180620_1551'), + ('cmsplugin_remote_form', '0005_auto_20200429_1442'), + ] + + operations = [ + migrations.AddField( + model_name='remoteform', + name='link_parameter', + field=models.CharField(default='', help_text='Adds a custom parameter onto the thanks page link', max_length=255), + ), + migrations.AddField( + model_name='remoteform', + name='thanks_page', + field=cms.models.fields.PageField(blank=True, help_text='Page to display after submitting the contact form', null=True, on_delete=django.db.models.deletion.CASCADE, to='cms.Page'), + ), + migrations.AlterField( + model_name='remoteform', + name='template', + field=models.CharField(choices=[('cmsplugin_remote_form_templates/default.html', 'Default - Label Inline'), ('cmsplugin_remote_form_templates/vertical_onecol.html', 'Vertical - One Col')], default='cmsplugin_remote_form/default.html', max_length=255), + ), + ] diff --git a/cmsplugin_remote_form/migrations/0007_auto_20200511_1108.py b/cmsplugin_remote_form/migrations/0007_auto_20200511_1108.py new file mode 100644 index 0000000..744e68f --- /dev/null +++ b/cmsplugin_remote_form/migrations/0007_auto_20200511_1108.py @@ -0,0 +1,28 @@ +# Generated by Django 2.2.12 on 2020-05-11 15:08 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('cmsplugin_remote_form', '0006_auto_20200504_1004'), + ] + + operations = [ + migrations.AlterField( + model_name='remoteform', + name='link_parameter', + field=models.CharField(blank=True, default='', help_text='Adds a custom parameter onto the thanks page link', max_length=255, null=True), + ), + migrations.AlterField( + model_name='remoteform', + name='post_url', + field=models.CharField(blank=True, default='', help_text='Post form data to remote endpoint', max_length=200, null=True, verbose_name='Remote URL'), + ), + migrations.AlterField( + model_name='remoteform', + name='thanks', + field=models.TextField(blank=True, default='', null=True, verbose_name='Message displayed after submitting the contact form.'), + ), + ] diff --git a/cmsplugin_remote_form/models.py b/cmsplugin_remote_form/models.py index 83dd966..4c3e4d3 100755 --- a/cmsplugin_remote_form/models.py +++ b/cmsplugin_remote_form/models.py @@ -1,7 +1,7 @@ import threading from collections import OrderedDict -from urlparse import urlparse +from urllib.parse import urlparse from django.conf import settings from django.db import models from django.utils.translation import ugettext_lazy as _ @@ -9,6 +9,7 @@ from django.utils.encoding import python_2_unicode_compatible from django.db.models import Model +from cms.models.fields import PageField from cms.models import CMSPlugin from adminsortable.models import SortableMixin from jsonfield import JSONField @@ -22,13 +23,30 @@ @python_2_unicode_compatible class RemoteForm(CMSPlugin): - post_url = models.CharField(_('Remote URL'), null=True, blank=False, max_length=200, - default='#remoteURL') + post_url = models.CharField(_('Remote URL'), null=True, blank=True, max_length=200, + default="", + help_text="Post form data to remote endpoint" + ) submit_button_text = models.CharField(_('Text for the Submit button.'), - blank=True, - max_length=30) + blank=True, + max_length=30 + ) on_submit = models.CharField(null=True, blank=True, max_length=400, help_text="Google Analytics Code") - thanks = models.TextField(_('Message displayed after submitting the contact form.')) + thanks = models.TextField(_('Message displayed after submitting the contact form.'), + default="", + null=True, + blank=True + ) + thanks_in_modal = models.BooleanField( + _('Show Thanks In Modal'), + default=True + ) + thanks_page = PageField(null=True, blank=True, + help_text="Page to display after submitting the contact form" + ) + link_parameter = models.CharField(max_length=255, null=True, blank=True, default="", + help_text="Adds a custom parameter onto the thanks page link" + ) notification_emails = models.CharField( _('Email Records To:'), help_text=_('multiple emails separated by commas'), @@ -43,10 +61,6 @@ class RemoteForm(CMSPlugin): blank=True, null=True ) - thanks_in_modal = models.BooleanField( - _('Show Thanks In Modal'), - default=True - ) collect_records = models.BooleanField( _('Collect Records'), default=True, @@ -98,7 +112,9 @@ def recaptcha_installed(): ('auto_hidden_input', _('CharField as HiddenInput')), ('auto_referral_page', _('Referral page as HiddenInput')), ('auto_GET_parameter', _('GET parameter as HiddenInput')), - ('CharFieldWithValidator', 'CharFieldWithValidator'),) + ('CharFieldWithValidator', 'CharFieldWithValidator'), + ('ChoiceField', 'ChoiceField') + ,) if recaptcha_installed(): FIELD_TYPE += (('ReCaptcha', 'reCAPTCHA'),) @@ -107,11 +123,11 @@ def recaptcha_installed(): class ExtraField(SortableMixin): """ """ - form = models.ForeignKey(RemoteForm, verbose_name=_("Contact Form")) + form = models.ForeignKey(RemoteForm, verbose_name=_("Contact Form"), on_delete=models.CASCADE) label = models.CharField(_('Label'), max_length=100, null=True, blank=True) name = models.CharField(_('Name'), max_length=100, default='') fieldType = models.CharField(max_length=100, choices=FIELD_TYPE) - initial = models.CharField(max_length=250, blank=True, null=True) + initial = models.CharField(max_length=4096, blank=True, null=True) placeholder = models.CharField( _('Placeholder'), max_length=250, blank=True, null=True) required = models.BooleanField( diff --git a/cmsplugin_remote_form/templates/cmsplugin_remote_form/.base.html b/cmsplugin_remote_form/templates/cmsplugin_remote_form/.base.html index 854d7c6..8d09dea 100644 --- a/cmsplugin_remote_form/templates/cmsplugin_remote_form/.base.html +++ b/cmsplugin_remote_form/templates/cmsplugin_remote_form/.base.html @@ -52,8 +52,6 @@ - {% endaddtoblock %} - {% addtoblock 'js' %} {% endaddtoblock %} {% endif %} +{% if show_thanks and object.thanks_page %} + {% addtoblock 'js-external' %} + + {% endaddtoblock %} +{% endif %} diff --git a/cmsplugin_remote_form/templates/cmsplugin_remote_form/default.html b/cmsplugin_remote_form/templates/cmsplugin_remote_form/default.html index 502e818..3b35631 100755 --- a/cmsplugin_remote_form/templates/cmsplugin_remote_form/default.html +++ b/cmsplugin_remote_form/templates/cmsplugin_remote_form/default.html @@ -1 +1 @@ -{% include 'cmsplugin_remote_form/.base.html' with form_layout='horizontal' %} \ No newline at end of file +{% include 'cmsplugin_remote_form/.base.html' %} \ No newline at end of file diff --git a/cmsplugin_remote_form/templates/cmsplugin_remote_form/horizontal.html b/cmsplugin_remote_form/templates/cmsplugin_remote_form/horizontal.html new file mode 100644 index 0000000..502e818 --- /dev/null +++ b/cmsplugin_remote_form/templates/cmsplugin_remote_form/horizontal.html @@ -0,0 +1 @@ +{% include 'cmsplugin_remote_form/.base.html' with form_layout='horizontal' %} \ No newline at end of file diff --git a/requirements.txt b/requirements.txt old mode 100644 new mode 100755 index d011463..38c0b58 --- a/requirements.txt +++ b/requirements.txt @@ -4,7 +4,7 @@ django-simple-math-captcha jsonfield django-localflavor six -django-bootstrap3==7.1.0 +django-bootstrap3>=12.0.0 requests -django-recaptcha==1.2.1 +django-recaptcha>=1.4.0 grequests \ No newline at end of file diff --git a/setup.py b/setup.py old mode 100644 new mode 100755