Story 2410: Legal Pages Wagtail Integration#2465
Conversation
julioest
left a comment
There was a problem hiding this comment.
Ran the test plan and everything worked great, edits and reverse migration round-tripped cleanly too. Nice work, approving! ❇️
jlchilders11
left a comment
There was a problem hiding this comment.
Overall, this looks like a good implementation! One change I'd like to see for when we do the big switchover
|
|
||
| def get_v3_context_data(self, **kwargs): | ||
| return {"last_updated": "2024-02-22"} | ||
| from pages.models import LegalPage |
There was a problem hiding this comment.
So, the intent of the RoutableHomePage model is to allow us to rely on the Wagtail router, rather than manually grabbing pages and populating them like this.
So we can use this methodology for now for testing/flagged switchover purposes, but as part of the deployment we should remove this view and have the url instead point to wagtail. I'd like to see those switchover notes added as a note so it is not lost.
Concrete changes
urls.py - Add a commented out route change for ease of switchover.
# path("terms-of-use/", include(wagtail_urls)),| return {"last_updated": "2024-02-17"} | ||
| from pages.models import LegalPage | ||
|
|
||
| return {"page": LegalPage.objects.live().filter(slug="privacy").first()} |
Issue: #2410
Summary & Context
Migrates Privacy Policy and Terms of Use content out of hardcoded templates into Wagtail-managed
LegalPageinstances, and consolidates the two near-identical templates into one sharedlegal_page.html. Editors can now update copy and the "Last Updated" date from the Wagtail admin instead of editing templates.Changes
LegalPageWagtail model (pages/models.py) —BasePagesubclass with aRichTextFieldbody using the project'sRICH_TEXT_FEATURES, parented underRoutableHomePage.0002_legalpage– schema for the new model.0003_create_legal_pages– data migration that seeds Privacy Policy and Terms of Use underRoutableHomePagewith prod-matching copy, and a reverse op that deletes them by slug.templates/v3/legal_page.html– new template renders anyLegalPage(title,last_published_at-driven "Last Updated", rich-text body).templates/v3/privacy_policy.html,templates/v3/terms_of_use.html– removed.core/views.py:TermsOfUseView/PrivacyPolicyViewnow resolve the correspondingLegalPageby slug (terms-of-use,privacy) and pass it to the template.last_updatedstrings — the visible date now comes frompage.last_published_at, so republishing in Wagtail updates it automatically.static/css/v3/legal-page.cssstatic/css/v3/header.csspadding (--space-default/--space-largeon desktop, reverts to--space-mediumon mobile) to match the legal page layout.Peer Review Testing (Wagtail CMS)
LegalPagemodel and seed the two pages:./manage.py createsuperuserif needed).RoutableHomePage) — you should see Privacy Policy and Terms of Use as children.legal-page.css.docker compose exec web ./manage.py migrate pages 0002→ The twoLegalPagerows should be deleted; re-runningmigrate pagesshould recreate them with the original seeded copy.Risks & Considerations
LegalPagerows existing. The data migration creates them, but environments that skip migrations or restore from a snapshot taken before0003_create_legal_pagesran will render an empty page. Confirm the migration runs on staging/prod.Last Updatedtimestamp matches the publish date of Wagtail publish date, so it is not the same as2024-02-22from Prod – we need to manually adjust the CMS0003_create_legal_pageswas hand-matched to current prodjc/wagtail-integrationfirst; rebasing this branch ontodevelopbefore that lands will surface unrelated changes.Screenshots
Self-review Checklist
Frontend