Conversation
…#710) Wagtail 7.x guards its admin submissions view with `isinstance(page, wagtail.contrib.forms.models.FormMixin)` and now calls `page.get_submissions()`. CodeRed's form pages did not inherit Wagtail's FormMixin, so viewing submissions for any CodeRed form 404'd. Have CoderedFormPage and CoderedStreamFormPage inherit FormMixin as the last base. FormMixin is a fieldless plain mixin, so no migration is needed; placing it last means it only supplies the get_submissions() / get_submissions_list_view_class() methods CodeRed lacks and satisfies the isinstance check, without shadowing CodeRed's or wagtail-flexible-forms' existing methods (notably StreamForm field handling). Add a regression test covering the admin forms index and the submissions view for both the standard and advanced (StreamField) form pages; these fail without the fix. Add release notes for v6.0.1. Fixes coderedcorp#710
Pre-existing spelling error flagged by codespell 2.4.3 in the Static Analysis CI job; unrelated to the form-submissions fix but included so the linters check passes on this PR.
|
Notes on the first CI run:
The functional change is unaffected by either. |
|
Update after the latest run (build 5158): unit tests, linters (spelling now fixed), and docs all pass. ✅ The only remaining red check is Code Coverage, and the log confirms it's not a coverage regression — |
|
Gentle bump — this has been open since July, with CI green apart from the known Since filing, I've applied this fix as a per-project override across six production sites running coderedcms 6.0.0 / Wagtail 7.4.2. That surfaced an additional symptom of the same root cause which isn't in the description above, and which I think strengthens the case for the fix:
Measured before and after on four separate projects, identical on each:
Happy to rebase onto current |
Fixes #710
Problem
On Wagtail 7.x, viewing form submissions in the Wagtail admin returns a 404. The Forms index lists the forms, but clicking through to a form's submissions (
/admin/forms/submissions/<id>/) fails.Wagtail 7.x hardened its admin submissions view to guard on the form type and use the new API:
CodeRed's
CoderedFormMixin/ form pages do not inherit Wagtail'swagtail.contrib.forms.models.FormMixin, so both theisinstanceguard and theget_submissions()call fail.Fix
Have
CoderedFormPageandCoderedStreamFormPageinherit Wagtail'sFormMixinas the last base:Why last, and why on the page classes rather than
CoderedFormMixin:FormMixinis a fieldless plain mixin → no migration (makemigrations --checkreports No changes detected).get_submissions(),get_submissions_list_view_class()) and satisfies theisinstancecheck — it never shadows CodeRed's own methods.CoderedFormMixininstead would insertFormMixinahead ofwagtail_flexible_forms.StreamFormMixininCoderedStreamFormPage's MRO, soFormMixin.get_form_fields()(which doesself.form_fields.all()) would shadow the StreamField handling and break advanced forms ('StreamValue' object has no attribute 'all'). Inheriting on the page classes, last, avoids that.Method resolution after the change:
isinstance(.., FormMixin)get_data_fieldsget_submissionsCoderedFormPageCoderedFormPage(unchanged)FormMixinCoderedStreamFormPageStreamFormMixin(unchanged)FormMixinTests
Adds
coderedcms/tests/test_forms.pycovering the admin forms index and the submissions view for both the standard and advanced (StreamField) form pages. These tests fail without the fix (both submission views 404) and pass with it.ruff check/ruff format --check: cleancodespell: cleanmakemigrations --check: No changes detectedDocs
Adds
docs/releases/v6.0.1.rst(backwards-compatible bug fix → patch) and links it in the releases index.