2
0

v1.0.3.rst 1.4 KB

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