Fix 404 viewing form submissions in admin on Wagtail 7.x (#710)#717
Open
bradrice wants to merge 2 commits into
Open
Fix 404 viewing form submissions in admin on Wagtail 7.x (#710)#717bradrice wants to merge 2 commits into
bradrice wants to merge 2 commits into
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.
Author
|
Notes on the first CI run:
The functional change is unaffected by either. |
Author
|
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 — |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.