Skip to content

Commit d7a8861

Browse files
committed
Merge branch 'dev' into release/1
2 parents 7930d15 + 462bf43 commit d7a8861

3 files changed

Lines changed: 42 additions & 1 deletion

File tree

coderedcms/models/page_models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1679,7 +1679,7 @@ def create_normal_submission(self, delete_self=True):
16791679
if "user" in submission_data:
16801680
submission_data["user"] = str(submission_data["user"])
16811681
submission = FormSubmission.objects.create(
1682-
form_data=json.dumps(submission_data, cls=StreamFormJSONEncoder),
1682+
form_data=submission_data,
16831683
page=self.page,
16841684
)
16851685

docs/releases/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Wagtail CRX (previously CodeRed CMS) follows the
1515
.. toctree::
1616
:maxdepth: 1
1717

18+
v1.0.3
1819
v1.0.2
1920
v1.0.1
2021
v1.0.0

docs/releases/v1.0.3.rst

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
v1.0.3 release notes
2+
====================
3+
4+
Bug fixes
5+
---------
6+
7+
* Save stream form submissions in the correct format.
8+
9+
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.
10+
11+
.. code-block:: python
12+
13+
"""
14+
Wagtail 3.0 switched ``FormSubmission.form_data`` from
15+
``TextField`` to ``JSONField``. However, after the Wagtail 3 migration
16+
``CoderedStreamForm`` continued to treat it like a ``TextField`` and
17+
manually dump stringified JSON into it. This migrations converts any
18+
residual strings to JSON.
19+
"""
20+
21+
import json
22+
from django.db import migrations
23+
from website.models import YOUR_STREAMFORM_PAGE_MODEL as MyStreamFormPage
24+
25+
def destringify(apps, schema_editor):
26+
for s in MyStreamFormPage.get_submission_class().objects.all():
27+
if isinstance(s.form_data, str):
28+
print(f"Fixing Submission {s.pk}")
29+
s.form_data = json.loads(s.form_data)
30+
s.save()
31+
32+
class Migration(migrations.Migration):
33+
34+
dependencies = [
35+
("coderedcms", "0035_remove_googleapisettings_site_and_more"),
36+
]
37+
38+
operations = [
39+
migrations.RunPython(destringify),
40+
]

0 commit comments

Comments
 (0)