From beccc2b5ff7b6b37d38d682891cdb1eaa72ba04d Mon Sep 17 00:00:00 2001 From: fabFrankDouwes <58548091+fabFrankDouwes@users.noreply.github.com> Date: Thu, 24 Nov 2022 10:28:40 +0100 Subject: [PATCH 1/9] Update setup.py - bump wagtail version --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 75c57602..c4e498f2 100644 --- a/setup.py +++ b/setup.py @@ -18,7 +18,7 @@ install_requires = [ - "wagtail>=2,<2.17", + "wagtail>=2,<5", "Unidecode>=0.04.14,<2.0", ] From b9612dfbfb9e8ee141ee7a9855fa4689c3a55073 Mon Sep 17 00:00:00 2001 From: fabFrankDouwes <58548091+fabFrankDouwes@users.noreply.github.com> Date: Fri, 25 Nov 2022 09:02:11 +0100 Subject: [PATCH 2/9] Update blocks.py add get_form_state() from FieldBlock --- wagtailstreamforms/blocks.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/wagtailstreamforms/blocks.py b/wagtailstreamforms/blocks.py index c314028d..edcea8c9 100644 --- a/wagtailstreamforms/blocks.py +++ b/wagtailstreamforms/blocks.py @@ -39,6 +39,11 @@ def to_python(self, value): return self.target_model.objects.get(pk=value) except self.target_model.DoesNotExist: return None + + def get_form_state(self, value): + return self.field.widget.format_value( + self.field.prepare_value(self.value_for_form(value)) + ) class WagtailFormBlock(blocks.StructBlock): From 422f443b68161fb46f294f97f219a04827f58186 Mon Sep 17 00:00:00 2001 From: fabFrankDouwes <58548091+fabFrankDouwes@users.noreply.github.com> Date: Fri, 25 Nov 2022 10:07:27 +0100 Subject: [PATCH 3/9] Update form.py FieldPanel --- wagtailstreamforms/models/form.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/wagtailstreamforms/models/form.py b/wagtailstreamforms/models/form.py index c9f06314..58e4c7ff 100644 --- a/wagtailstreamforms/models/form.py +++ b/wagtailstreamforms/models/form.py @@ -8,7 +8,6 @@ MultiFieldPanel, ObjectList, PageChooserPanel, - StreamFieldPanel, TabbedInterface, ) from wagtail.core.models import Site @@ -90,7 +89,7 @@ class AbstractForm(models.Model): PageChooserPanel("post_redirect_page"), ] - field_panels = [StreamFieldPanel("fields")] + field_panels = [FieldPanel("fields")] edit_handler = TabbedInterface( [ From 8dd0bdd0aa62684a71948d2ce3ef507827d53faf Mon Sep 17 00:00:00 2001 From: fabFrankDouwes <58548091+fabFrankDouwes@users.noreply.github.com> Date: Fri, 25 Nov 2022 10:08:37 +0100 Subject: [PATCH 4/9] Update form.py use_json_field --- wagtailstreamforms/models/form.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wagtailstreamforms/models/form.py b/wagtailstreamforms/models/form.py index 58e4c7ff..0eb548ff 100644 --- a/wagtailstreamforms/models/form.py +++ b/wagtailstreamforms/models/form.py @@ -42,7 +42,7 @@ class AbstractForm(models.Model): template_name = models.CharField( _("Template"), max_length=255, choices=get_setting("FORM_TEMPLATES") ) - fields = FormFieldsStreamField([], verbose_name=_("Fields")) + fields = FormFieldsStreamField([], verbose_name=_("Fields"), use_json_field=True) submit_button_text = models.CharField( _("Submit button text"), max_length=100, default="Submit" ) From 5ec2214c19ed189eb58d83ebfc692377b3dc1e9e Mon Sep 17 00:00:00 2001 From: fabFrankDouwes <58548091+fabFrankDouwes@users.noreply.github.com> Date: Fri, 25 Nov 2022 10:23:45 +0100 Subject: [PATCH 5/9] Create 0003_alter_form_fields.py --- .../migrations/0003_alter_form_fields.py | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 wagtailstreamforms/migrations/0003_alter_form_fields.py diff --git a/wagtailstreamforms/migrations/0003_alter_form_fields.py b/wagtailstreamforms/migrations/0003_alter_form_fields.py new file mode 100644 index 00000000..3f2e40ce --- /dev/null +++ b/wagtailstreamforms/migrations/0003_alter_form_fields.py @@ -0,0 +1,20 @@ +# Generated by Django 3.2.16 on 2022-11-25 10:19 + +from django.db import migrations +import wagtail.blocks +import wagtailstreamforms.streamfield + + +class Migration(migrations.Migration): + + dependencies = [ + ('wagtailstreamforms', '0002_form_site'), + ] + + operations = [ + migrations.AlterField( + model_name='form', + name='fields', + field=wagtailstreamforms.streamfield.FormFieldsStreamField([('singleline', wagtail.blocks.StructBlock([('label', wagtail.blocks.CharBlock()), ('help_text', wagtail.blocks.CharBlock(required=False)), ('required', wagtail.blocks.BooleanBlock(required=False)), ('default_value', wagtail.blocks.CharBlock(required=False)), ('placeholder', wagtail.blocks.CharBlock(required=False))], icon='placeholder', label='Text field (single line)')), ('multiline', wagtail.blocks.StructBlock([('label', wagtail.blocks.CharBlock()), ('help_text', wagtail.blocks.CharBlock(required=False)), ('required', wagtail.blocks.BooleanBlock(required=False)), ('default_value', wagtail.blocks.CharBlock(required=False)), ('placeholder', wagtail.blocks.CharBlock(required=False))], icon='placeholder', label='Text field (multi line)')), ('email', wagtail.blocks.StructBlock([('label', wagtail.blocks.CharBlock()), ('help_text', wagtail.blocks.CharBlock(required=False)), ('required', wagtail.blocks.BooleanBlock(required=False)), ('default_value', wagtail.blocks.CharBlock(required=False)), ('placeholder', wagtail.blocks.CharBlock(required=False))], icon='mail', label=None)), ('dropdown', wagtail.blocks.StructBlock([('label', wagtail.blocks.CharBlock()), ('help_text', wagtail.blocks.CharBlock(required=False)), ('required', wagtail.blocks.BooleanBlock(required=False)), ('empty_label', wagtail.blocks.CharBlock(required=False)), ('choices', wagtail.blocks.ListBlock(wagtail.blocks.CharBlock(label='Option')))], icon='arrow-down-big', label='Dropdown field')), ('radio', wagtail.blocks.StructBlock([('label', wagtail.blocks.CharBlock()), ('help_text', wagtail.blocks.CharBlock(required=False)), ('required', wagtail.blocks.BooleanBlock(required=False)), ('choices', wagtail.blocks.ListBlock(wagtail.blocks.CharBlock(label='Option')))], icon='radio-empty', label='Radio buttons')), ('checkbox', wagtail.blocks.StructBlock([('label', wagtail.blocks.CharBlock()), ('help_text', wagtail.blocks.CharBlock(required=False)), ('required', wagtail.blocks.BooleanBlock(required=False))], icon='tick-inverse', label='Checkbox field')), ('singlefile', wagtail.blocks.StructBlock([('label', wagtail.blocks.CharBlock()), ('help_text', wagtail.blocks.CharBlock(required=False)), ('required', wagtail.blocks.BooleanBlock(required=False))], icon='doc-full-inverse', label='File field')), ('recaptcha', wagtail.blocks.StructBlock([('label', wagtail.blocks.CharBlock()), ('help_text', wagtail.blocks.CharBlock(required=False))], icon='success', label='ReCAPTCHA field'))], use_json_field=True, verbose_name='Fields'), + ), + ] From 534bc955c8b2da5b30262ae31685e7e82ba8da06 Mon Sep 17 00:00:00 2001 From: fabFrankDouwes <58548091+fabFrankDouwes@users.noreply.github.com> Date: Fri, 25 Nov 2022 10:24:12 +0100 Subject: [PATCH 6/9] Update streamfield.py --- wagtailstreamforms/streamfield.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wagtailstreamforms/streamfield.py b/wagtailstreamforms/streamfield.py index 454b9be3..5e5d321d 100644 --- a/wagtailstreamforms/streamfield.py +++ b/wagtailstreamforms/streamfield.py @@ -43,6 +43,6 @@ def dependencies(self): class FormFieldsStreamField(StreamField): - def __init__(self, block_types, **kwargs): - super().__init__(block_types, **kwargs) + def __init__(self, block_types, use_json_field=None, **kwargs): + super().__init__(block_types, use_json_field=use_json_field, **kwargs) self.stream_block = FormFieldStreamBlock(block_types, required=not self.blank) From eb87af77ad85fad1ac8c3325dd1bb09b0cadabaa Mon Sep 17 00:00:00 2001 From: fabFrankDouwes <58548091+fabFrankDouwes@users.noreply.github.com> Date: Fri, 25 Nov 2022 10:28:54 +0100 Subject: [PATCH 7/9] Update README.rst --- README.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.rst b/README.rst index a35614a6..4188d53f 100644 --- a/README.rst +++ b/README.rst @@ -1,6 +1,8 @@ Wagtail StreamForms =================== +This seems to work with wagtail 4.1.1 + |CircleCI| |Codecov| Allows you to build forms in the CMS admin area and add them to any StreamField in your site. From 05e3dbcd39ea330c9db93613f3f2bbba6b4d3251 Mon Sep 17 00:00:00 2001 From: fabFrankDouwes <58548091+fabFrankDouwes@users.noreply.github.com> Date: Fri, 2 Dec 2022 09:12:37 +0100 Subject: [PATCH 8/9] Update README.rst older versions update --- README.rst | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/README.rst b/README.rst index 4188d53f..8a5691b0 100644 --- a/README.rst +++ b/README.rst @@ -1,8 +1,6 @@ Wagtail StreamForms =================== -This seems to work with wagtail 4.1.1 - |CircleCI| |Codecov| Allows you to build forms in the CMS admin area and add them to any StreamField in your site. @@ -27,11 +25,17 @@ If you are using a version of wagtail 1.x, then the latest compatible version of $ pip install wagtailstreamforms<2 -Other wise you must install a version of this package from 2 onwards: +If you are using a version of wagtail 2.x, then the latest compatible version of this package is 3.19.1: + +.. code:: bash + + $ pip install wagtailstreamforms<3.19.2 + +Otherwise you must install a version of this package from 2 onwards: .. code:: bash - $ pip install wagtailstreamforms>=2 + $ pip install wagtailstreamforms>=3.19.2 What else is included? ---------------------- From 9cf241854271ff5265d99f3ceecc7762ec1212d3 Mon Sep 17 00:00:00 2001 From: fabFrankDouwes <58548091+fabFrankDouwes@users.noreply.github.com> Date: Fri, 2 Dec 2022 09:14:46 +0100 Subject: [PATCH 9/9] Update __init__.py update version number --- wagtailstreamforms/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wagtailstreamforms/__init__.py b/wagtailstreamforms/__init__.py index 8403eee1..94774196 100644 --- a/wagtailstreamforms/__init__.py +++ b/wagtailstreamforms/__init__.py @@ -2,6 +2,6 @@ # major.minor.patch.release.number # release must be one of alpha, beta, rc, or final -VERSION = (3, 19, 1, "final", 1) +VERSION = (3, 19, 2, "final", 1) __version__ = get_version(VERSION)