From ee1d368c0b7641f4dc5c17c5f65458e64c84e273 Mon Sep 17 00:00:00 2001 From: Greg Date: Wed, 15 Jan 2020 22:56:18 -0500 Subject: [PATCH 01/19] Changed urlparse to urllib.parse for python3 --- 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 83dd966..ea9fcc9 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 _ From 8e98adeddd7f6fd343cbd069c6919f7d0abd40f2 Mon Sep 17 00:00:00 2001 From: Greg Date: Wed, 15 Jan 2020 23:09:08 -0500 Subject: [PATCH 02/19] on_delete add for Python3 --- 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 ea9fcc9..4e19eb0 100755 --- a/cmsplugin_remote_form/models.py +++ b/cmsplugin_remote_form/models.py @@ -107,7 +107,7 @@ 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.SET_NULL) 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) From ab5f745f1a7609749e5a359ab3dea019bfb99c5f Mon Sep 17 00:00:00 2001 From: Jared Proffitt Date: Thu, 13 Feb 2020 12:58:25 -0600 Subject: [PATCH 03/19] running 2to3 to convert to python 3 --- README.md | 142 +----------------- cmsplugin_remote_form/actions.py | 4 +- cmsplugin_remote_form/cms_plugins.py | 10 +- .../migrations/0001_initial.py | 2 +- .../migrations/0002_auto_20170421_1127.py | 2 +- .../migrations/0003_remoteform_on_submit.py | 2 +- .../0004_remoteform_notification_emails.py | 2 +- cmsplugin_remote_form/models.py | 4 +- 8 files changed, 17 insertions(+), 151 deletions(-) diff --git a/README.md b/README.md index a10bd06..18238b8 100644 --- 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.1 - Unreleased +- Drop python 2 support +- Drop support for django < 2.2 + \ No newline at end of file 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..d342524 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, @@ -85,8 +85,8 @@ 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 @@ -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/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/models.py b/cmsplugin_remote_form/models.py index 4e19eb0..cb1c23a 100755 --- a/cmsplugin_remote_form/models.py +++ b/cmsplugin_remote_form/models.py @@ -152,7 +152,7 @@ def is_processed(self): return False def __str__(self): - return _(u"Record for %(contact)s recorded on %(date)s") % {'contact': self.contact_form, + return _("Record for %(contact)s recorded on %(date)s") % {'contact': self.contact_form, 'date': self.date_of_entry.strftime('%d. %b %Y')} def get_ordered_data(self): @@ -168,4 +168,4 @@ def get_ordered_data(self): return ordered_dict def combined_data_dict(self): - return {k: v for d in self.data for k, v in d.items()} + return {k: v for d in self.data for k, v in list(d.items())} From b7b97045530d671119b5c0a03e69d460780fb38e Mon Sep 17 00:00:00 2001 From: Jared Proffitt Date: Thu, 13 Feb 2020 14:16:37 -0600 Subject: [PATCH 04/19] bump version --- README.md | 2 +- cmsplugin_remote_form/__init__.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 18238b8..12b909d 100644 --- a/README.md +++ b/README.md @@ -96,7 +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.1 - Unreleased +### 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..6e91470 100755 --- a/cmsplugin_remote_form/__init__.py +++ b/cmsplugin_remote_form/__init__.py @@ -1 +1 @@ -__version__ = "1.1.1" +__version__ = "1.2b1" From 261fa9c1a0eacfd34bc2b5fe283626b2379822c6 Mon Sep 17 00:00:00 2001 From: Jared Proffitt Date: Thu, 13 Feb 2020 16:23:15 -0600 Subject: [PATCH 05/19] fix on_delete --- cmsplugin_remote_form/__init__.py | 2 +- cmsplugin_remote_form/models.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cmsplugin_remote_form/__init__.py b/cmsplugin_remote_form/__init__.py index 6e91470..a7bbeae 100755 --- a/cmsplugin_remote_form/__init__.py +++ b/cmsplugin_remote_form/__init__.py @@ -1 +1 @@ -__version__ = "1.2b1" +__version__ = "1.2b2" diff --git a/cmsplugin_remote_form/models.py b/cmsplugin_remote_form/models.py index cb1c23a..c1202bf 100755 --- a/cmsplugin_remote_form/models.py +++ b/cmsplugin_remote_form/models.py @@ -107,7 +107,7 @@ def recaptcha_installed(): class ExtraField(SortableMixin): """ """ - form = models.ForeignKey(RemoteForm, verbose_name=_("Contact Form"), on_delete=models.SET_NULL) + 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) From ed5bbcb525f6724eb342ca974e2313910cd4ff7f Mon Sep 17 00:00:00 2001 From: Jared Proffitt Date: Mon, 17 Feb 2020 10:05:34 -0600 Subject: [PATCH 06/19] force newer version of django-bootstrap3 --- cmsplugin_remote_form/__init__.py | 2 +- requirements.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cmsplugin_remote_form/__init__.py b/cmsplugin_remote_form/__init__.py index a7bbeae..016c9fc 100755 --- a/cmsplugin_remote_form/__init__.py +++ b/cmsplugin_remote_form/__init__.py @@ -1 +1 @@ -__version__ = "1.2b2" +__version__ = "1.2b3" diff --git a/requirements.txt b/requirements.txt index d011463..76f24df 100644 --- 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 grequests \ No newline at end of file From db6720c864ae52819a0708ebd4d000c9fc3353e1 Mon Sep 17 00:00:00 2001 From: Jared Proffitt Date: Mon, 17 Feb 2020 10:28:47 -0600 Subject: [PATCH 07/19] require new version of django-recaptcha --- cmsplugin_remote_form/__init__.py | 2 +- requirements.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cmsplugin_remote_form/__init__.py b/cmsplugin_remote_form/__init__.py index 016c9fc..0476fa9 100755 --- a/cmsplugin_remote_form/__init__.py +++ b/cmsplugin_remote_form/__init__.py @@ -1 +1 @@ -__version__ = "1.2b3" +__version__ = "1.2b4" diff --git a/requirements.txt b/requirements.txt index 76f24df..38c0b58 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,5 +6,5 @@ django-localflavor six django-bootstrap3>=12.0.0 requests -django-recaptcha==1.2.1 +django-recaptcha>=1.4.0 grequests \ No newline at end of file From 9ba094a208a459c1c75d5614ded3f5cb881110f2 Mon Sep 17 00:00:00 2001 From: Jared Proffitt Date: Fri, 20 Mar 2020 17:57:52 -0500 Subject: [PATCH 08/19] Use response.text for fix in python 3 --- cmsplugin_remote_form/cms_plugins.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmsplugin_remote_form/cms_plugins.py b/cmsplugin_remote_form/cms_plugins.py index d342524..e0f13f1 100755 --- a/cmsplugin_remote_form/cms_plugins.py +++ b/cmsplugin_remote_form/cms_plugins.py @@ -89,7 +89,7 @@ def post_to_remote(self, instance, request, cleaned_data): 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", From 56fa642daf37bfd92a43f02a676e3628b852efb3 Mon Sep 17 00:00:00 2001 From: Jared Proffitt Date: Fri, 20 Mar 2020 17:59:01 -0500 Subject: [PATCH 09/19] bump version --- 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 a82b376..72f26f5 100755 --- a/cmsplugin_remote_form/__init__.py +++ b/cmsplugin_remote_form/__init__.py @@ -1 +1 @@ -__version__ = "1.1.1" +__version__ = "1.1.2" From fe8e31b10aae19f6cd0530775da6067e109c5a10 Mon Sep 17 00:00:00 2001 From: Jared Proffitt Date: Fri, 20 Mar 2020 18:00:20 -0500 Subject: [PATCH 10/19] bump version --- 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 0476fa9..a717730 100755 --- a/cmsplugin_remote_form/__init__.py +++ b/cmsplugin_remote_form/__init__.py @@ -1 +1 @@ -__version__ = "1.2b4" +__version__ = "1.2b5" From a8784acc3d1d697ea02b6cd65c3db44936d367d8 Mon Sep 17 00:00:00 2001 From: Georg Zimmer Date: Wed, 29 Apr 2020 13:38:03 -0400 Subject: [PATCH 11/19] adding choice fields --- cmsplugin_remote_form/models.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cmsplugin_remote_form/models.py b/cmsplugin_remote_form/models.py index c1202bf..f28e828 100755 --- a/cmsplugin_remote_form/models.py +++ b/cmsplugin_remote_form/models.py @@ -98,7 +98,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'), + ('select_from_list', 'ChoiceField'), + ) if recaptcha_installed(): FIELD_TYPE += (('ReCaptcha', 'reCAPTCHA'),) From 426a4d9df2ae61f8b5289dece43529ff418cdd84 Mon Sep 17 00:00:00 2001 From: Georg Zimmer Date: Wed, 29 Apr 2020 15:21:18 -0400 Subject: [PATCH 12/19] added choice field with choices coming from initial. --- .../migrations/0005_auto_20200429_1442.py | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 cmsplugin_remote_form/migrations/0005_auto_20200429_1442.py 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), + ), + ] From c431d7f0c2704fa341aa4f680a21d33f8cc7cc41 Mon Sep 17 00:00:00 2001 From: Georg Zimmer Date: Wed, 29 Apr 2020 15:22:43 -0400 Subject: [PATCH 13/19] added choice field with choices coming from initial. --- cmsplugin_remote_form/forms.py | 137 ++++++++++++++++++++------------ cmsplugin_remote_form/models.py | 10 +-- 2 files changed, 89 insertions(+), 58 deletions(-) diff --git a/cmsplugin_remote_form/forms.py b/cmsplugin_remote_form/forms.py index d794118..e2dcaf7 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,112 @@ 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": self.extra_field_factory( extraField, - forms.CharField, - validators=get_validators()) + forms.ChoiceField, + choices=[ + (c.strip(), c.strip()) for c in extraField.initial.split(",") + ], + ) + 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/models.py b/cmsplugin_remote_form/models.py index f28e828..1f81c74 100755 --- a/cmsplugin_remote_form/models.py +++ b/cmsplugin_remote_form/models.py @@ -99,8 +99,8 @@ def recaptcha_installed(): ('auto_referral_page', _('Referral page as HiddenInput')), ('auto_GET_parameter', _('GET parameter as HiddenInput')), ('CharFieldWithValidator', 'CharFieldWithValidator'), - ('select_from_list', 'ChoiceField'), - ) + ('ChoiceField', 'ChoiceField') + ,) if recaptcha_installed(): FIELD_TYPE += (('ReCaptcha', 'reCAPTCHA'),) @@ -113,7 +113,7 @@ class ExtraField(SortableMixin): 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( @@ -154,7 +154,7 @@ def is_processed(self): return False def __str__(self): - return _("Record for %(contact)s recorded on %(date)s") % {'contact': self.contact_form, + return _(u"Record for %(contact)s recorded on %(date)s") % {'contact': self.contact_form, 'date': self.date_of_entry.strftime('%d. %b %Y')} def get_ordered_data(self): @@ -170,4 +170,4 @@ def get_ordered_data(self): return ordered_dict def combined_data_dict(self): - return {k: v for d in self.data for k, v in list(d.items())} + return {k: v for d in self.data for k, v in d.items()} From fb78441f8e982c3a019a13e2c74ed811f448082e Mon Sep 17 00:00:00 2001 From: Georg Zimmer Date: Wed, 29 Apr 2020 15:40:11 -0400 Subject: [PATCH 14/19] one more tweak --- cmsplugin_remote_form/forms.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/cmsplugin_remote_form/forms.py b/cmsplugin_remote_form/forms.py index e2dcaf7..2007b67 100755 --- a/cmsplugin_remote_form/forms.py +++ b/cmsplugin_remote_form/forms.py @@ -109,12 +109,14 @@ def __init__(self, contactFormInstance, request, *args, **kwargs): extraField, forms.CharField, validators=get_validators() ) elif extraField.fieldType == "ChoiceField": + if extraField.initial: + choices = [ + (c.strip(), c.strip()) for c in extraField.initial.split(",") + ] self.extra_field_factory( extraField, forms.ChoiceField, - choices=[ - (c.strip(), c.strip()) for c in extraField.initial.split(",") - ], + choices=choices, ) self.make_select2(extraField) From dff57ebf9a25bf95e469dd34113997dc691caa05 Mon Sep 17 00:00:00 2001 From: Georg Zimmer Date: Wed, 29 Apr 2020 15:45:36 -0400 Subject: [PATCH 15/19] added choice field with choices coming from initial. --- cmsplugin_remote_form/forms.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cmsplugin_remote_form/forms.py b/cmsplugin_remote_form/forms.py index 2007b67..0ea638d 100755 --- a/cmsplugin_remote_form/forms.py +++ b/cmsplugin_remote_form/forms.py @@ -109,10 +109,12 @@ def __init__(self, contactFormInstance, request, *args, **kwargs): 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.ChoiceField, From 578a698d4d4cd9e2d09b2f9daba1c7ddf17dfd30 Mon Sep 17 00:00:00 2001 From: Georg Zimmer Date: Wed, 29 Apr 2020 16:17:08 -0400 Subject: [PATCH 16/19] increase version --- 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 a717730..b15aecf 100755 --- a/cmsplugin_remote_form/__init__.py +++ b/cmsplugin_remote_form/__init__.py @@ -1 +1 @@ -__version__ = "1.2b5" +__version__ = "1.2b6" From 1a9ad8357ea95caf14b1584a929da9df5a9e98d3 Mon Sep 17 00:00:00 2001 From: Georg Zimmer Date: Mon, 4 May 2020 11:26:09 -0400 Subject: [PATCH 17/19] thanks page and link parameter added --- cmsplugin_remote_form/__init__.py | 2 +- cmsplugin_remote_form/cms_plugins.py | 2 +- .../migrations/0006_auto_20200504_1004.py | 31 +++++++++++++++++++ cmsplugin_remote_form/models.py | 14 ++++++--- .../cmsplugin_remote_form/.base.html | 9 ++++-- 5 files changed, 49 insertions(+), 9 deletions(-) create mode 100644 cmsplugin_remote_form/migrations/0006_auto_20200504_1004.py diff --git a/cmsplugin_remote_form/__init__.py b/cmsplugin_remote_form/__init__.py index b15aecf..a85806d 100755 --- a/cmsplugin_remote_form/__init__.py +++ b/cmsplugin_remote_form/__init__.py @@ -1 +1 @@ -__version__ = "1.2b6" +__version__ = "1.2b7" diff --git a/cmsplugin_remote_form/cms_plugins.py b/cmsplugin_remote_form/cms_plugins.py index e0f13f1..e08b5de 100755 --- a/cmsplugin_remote_form/cms_plugins.py +++ b/cmsplugin_remote_form/cms_plugins.py @@ -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 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/models.py b/cmsplugin_remote_form/models.py index 1f81c74..64fbe87 100755 --- a/cmsplugin_remote_form/models.py +++ b/cmsplugin_remote_form/models.py @@ -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 @@ -28,7 +29,14 @@ class RemoteForm(CMSPlugin): 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="") + 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, 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 +51,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, 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 %} From b54beef555fea699505d30db1bd06dec871602e7 Mon Sep 17 00:00:00 2001 From: Greg Date: Mon, 11 May 2020 11:05:07 -0400 Subject: [PATCH 18/19] Attempting model changes - no migrations yet --- .python-version | 1 + AUTHORS.txt | 0 LICENSE | 0 MANIFEST.in | 0 README.md | 0 cmsplugin_remote_form/models.py | 26 +++++++++++++------ .../cmsplugin_remote_form/default.html | 2 +- .../cmsplugin_remote_form/horizontal.html | 1 + requirements.txt | 0 setup.py | 0 10 files changed, 21 insertions(+), 9 deletions(-) create mode 100644 .python-version mode change 100644 => 100755 AUTHORS.txt mode change 100644 => 100755 LICENSE mode change 100644 => 100755 MANIFEST.in mode change 100644 => 100755 README.md create mode 100644 cmsplugin_remote_form/templates/cmsplugin_remote_form/horizontal.html mode change 100644 => 100755 requirements.txt mode change 100644 => 100755 setup.py 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 diff --git a/cmsplugin_remote_form/models.py b/cmsplugin_remote_form/models.py index 64fbe87..4c3e4d3 100755 --- a/cmsplugin_remote_form/models.py +++ b/cmsplugin_remote_form/models.py @@ -23,20 +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.'), default="") + 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, default="", help_text="Adds a custom parameter onto the thanks page link") - + 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'), 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 diff --git a/setup.py b/setup.py old mode 100644 new mode 100755 From 804e67ccc18964223247b39cc6e359f977a16556 Mon Sep 17 00:00:00 2001 From: Georg Zimmer Date: Mon, 11 May 2020 11:13:18 -0400 Subject: [PATCH 19/19] migration --- .../migrations/0007_auto_20200511_1108.py | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 cmsplugin_remote_form/migrations/0007_auto_20200511_1108.py 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.'), + ), + ]