From 8801a49da8d868b667832c3d49d26649f7101064 Mon Sep 17 00:00:00 2001 From: Alex Tomkins Date: Fri, 20 Jan 2023 22:02:57 +0000 Subject: [PATCH] Add missing wagtailadmin_tags in workflow_state_approved.html template --- CHANGELOG.txt | 1 + .../workflow_state_approved.html | 2 +- wagtail/admin/tests/test_workflows.py | 37 ++++++++++++++++++- 3 files changed, 38 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 16ef2224c1..df75c43788 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -86,6 +86,7 @@ Changelog * Fix: Center-align StreamField and rich text block picker buttons with the dotted guide line (Thibaud Colas) * Fix: Search bar in chooser modals now performs autocomplete searches under PostgreSQL (Matt Westcott) * Fix: Server-side document filenames are preserved when replacing a document file (Suyash Singh, Matt Westcott) + * Fix: Add missing wagtailadmin_tags in `workflow_state_approved.html` template (Alex Tomkins) * Docs: Add custom permissions section to permissions documentation page (Dan Hayden) * Docs: Add documentation for how to get started with contributing translations for the Wagtail admin (Ogunbanjo Oluwadamilare) * Docs: Officially recommend `fnm` over `nvm` in development documentation (LB (Ben) Johnston) diff --git a/wagtail/admin/templates/wagtailadmin/notifications/workflow_state_approved.html b/wagtail/admin/templates/wagtailadmin/notifications/workflow_state_approved.html index c290fcde52..c6bb519677 100644 --- a/wagtail/admin/templates/wagtailadmin/notifications/workflow_state_approved.html +++ b/wagtail/admin/templates/wagtailadmin/notifications/workflow_state_approved.html @@ -1,5 +1,5 @@ {% extends 'wagtailadmin/notifications/base.html' %} -{% load i18n %} +{% load i18n wagtailadmin_tags %} {% block content %} {% if page %} diff --git a/wagtail/admin/tests/test_workflows.py b/wagtail/admin/tests/test_workflows.py index fa7d7a75c5..b0c95b7d21 100644 --- a/wagtail/admin/tests/test_workflows.py +++ b/wagtail/admin/tests/test_workflows.py @@ -1306,6 +1306,10 @@ class TestSubmitPageToWorkflow(BasePageWorkflowTests): ) self.assertIn("http://admin.example.com/admin/", workflow_message.body) + @override_settings(WAGTAILADMIN_NOTIFICATION_USE_HTML=True) + def test_submit_sends_html_mail(self): + self.test_submit_sends_mail() + @override_settings(WAGTAILADMIN_BASE_URL=None) def test_submit_sends_mail_without_base_url(self): # With a missing WAGTAILADMIN_BASE_URL setting, we won't be able to construct absolute URLs @@ -1338,6 +1342,10 @@ class TestSubmitPageToWorkflow(BasePageWorkflowTests): workflow_message.body, ) + @override_settings(WAGTAILADMIN_NOTIFICATION_USE_HTML=True) + def test_submit_sends_html_mail_without_base_url(self): + self.test_submit_sends_mail_without_base_url() + @mock.patch.object( EmailMultiAlternatives, "send", side_effect=IOError("Server down") ) @@ -1414,13 +1422,30 @@ class TestSubmitPageToWorkflow(BasePageWorkflowTests): # Submit self.post("submit") - msg_headers = set(mail.outbox[0].message().items()) + message = mail.outbox[0].message() + msg_headers = set(message.items()) headers = {("Auto-Submitted", "auto-generated")} self.assertTrue( headers.issubset(msg_headers), msg="Message is missing the Auto-Submitted header.", ) + self.assertFalse(message.is_multipart()) + + @override_settings(WAGTAILADMIN_NOTIFICATION_USE_HTML=True) + def test_html_email_headers(self): + self.post("submit") + + message = mail.outbox[0].message() + msg_headers = set(message.items()) + headers = {("Auto-Submitted", "auto-generated")} + self.assertTrue( + headers.issubset(msg_headers), + msg="Message is missing the Auto-Submitted header.", + ) + + self.assertTrue(mail.outbox[0].message().is_multipart()) + class TestSubmitSnippetToWorkflow(TestSubmitPageToWorkflow, BaseSnippetWorkflowTests): pass @@ -2425,6 +2450,11 @@ class TestPageNotificationPreferences(BasePageWorkflowTests): self.assertEqual(len(workflow_rejected_emails), 0) +@override_settings(WAGTAILADMIN_NOTIFICATION_USE_HTML=True) +class TestPageNotificationPreferencesHTML(TestPageNotificationPreferences): + pass + + class TestSnippetNotificationPreferences( TestPageNotificationPreferences, BaseSnippetWorkflowTests ): @@ -2436,6 +2466,11 @@ class TestSnippetNotificationPreferences( ) +@override_settings(WAGTAILADMIN_NOTIFICATION_USE_HTML=True) +class TestSnippetNotificationPreferencesHTML(TestSnippetNotificationPreferences): + pass + + class TestDisableViews(BasePageWorkflowTests): def test_disable_workflow(self): """Test that deactivating a workflow sets it to inactive and cancels in progress states"""