Browse Source

Merge branch 'dev' into release/1

Vince Salvino 2 years ago
parent
commit
d7a88612ae
3 changed files with 42 additions and 1 deletions
  1. 1 1
      coderedcms/models/page_models.py
  2. 1 0
      docs/releases/index.rst
  3. 40 0
      docs/releases/v1.0.3.rst

+ 1 - 1
coderedcms/models/page_models.py

@@ -1679,7 +1679,7 @@ class CoderedSessionFormSubmission(SessionFormSubmission):
         if "user" in submission_data:
             submission_data["user"] = str(submission_data["user"])
         submission = FormSubmission.objects.create(
-            form_data=json.dumps(submission_data, cls=StreamFormJSONEncoder),
+            form_data=submission_data,
             page=self.page,
         )
 

+ 1 - 0
docs/releases/index.rst

@@ -15,6 +15,7 @@ Wagtail CRX (previously CodeRed CMS) follows the
 .. toctree::
     :maxdepth: 1
 
+    v1.0.3
     v1.0.2
     v1.0.1
     v1.0.0

+ 40 - 0
docs/releases/v1.0.3.rst

@@ -0,0 +1,40 @@
+v1.0.3 release notes
+====================
+
+Bug fixes
+---------
+
+* Save stream form submissions in the correct format.
+
+Note: This bug was introduced in v1.0.0. If you were actively using ``CoderedStreamFormPage`` or ``CoderedStreamFormMixin`` (not the default configuration) with version 1.0.0, 1.0.1, or 1.0.2; and you are getting 500 errors when trying to view stream form submissions in the Wagtail admin, create a migration file with the following code or run it directly.
+
+.. code-block:: python
+
+   """
+   Wagtail 3.0 switched ``FormSubmission.form_data`` from
+   ``TextField`` to ``JSONField``. However, after the Wagtail 3 migration
+   ``CoderedStreamForm`` continued to treat it like a ``TextField`` and
+   manually dump stringified JSON into it. This migrations converts any
+   residual strings to JSON.
+   """
+
+   import json
+   from django.db import migrations
+   from website.models import YOUR_STREAMFORM_PAGE_MODEL as MyStreamFormPage
+
+   def destringify(apps, schema_editor):
+       for s in MyStreamFormPage.get_submission_class().objects.all():
+           if isinstance(s.form_data, str):
+               print(f"Fixing Submission {s.pk}")
+               s.form_data = json.loads(s.form_data)
+               s.save()
+
+   class Migration(migrations.Migration):
+
+       dependencies = [
+           ("coderedcms", "0035_remove_googleapisettings_site_and_more"),
+       ]
+
+       operations = [
+           migrations.RunPython(destringify),
+       ]