diff --git a/CHANGELOG.txt b/CHANGELOG.txt index c08781989e..a57a707a9c 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -15,6 +15,7 @@ Changelog * Remove `wagtail.publish` log action on aliases when they are created from live source pages or the source page is published (Dan Braghis) * Remove `wagtail.unpublish` log action on aliases when source page is unpublished (Dan Braghis) * Fix: Ensure that StreamField's `FieldBlock`s correctly set the `required` and `aria-describedby` attributes (Storm Heg) + * Fix: Avoid an error when the moderation panel (admin dashboard) contains both snippets and private pages (Matt Westcott) * Docs: Document `WAGTAILADMIN_BASE_URL` on "Integrating Wagtail into a Django project" page (Shreshth Srivastava) * Docs: Replace incorrect screenshot for authors listing on tutorial (Shreshth Srivastava) * Maintenance: Fix snippet search test to work on non-fallback database backends (Matt Westcott) diff --git a/docs/releases/5.2.md b/docs/releases/5.2.md index 745a418ba2..5076aae4af 100644 --- a/docs/releases/5.2.md +++ b/docs/releases/5.2.md @@ -28,6 +28,7 @@ depth: 1 ### Bug fixes * Ensure that StreamField's `FieldBlock`s correctly set the `required` and `aria-describedby` attributes (Storm Heg) + * Avoid an error when the moderation panel (admin dashboard) contains both snippets and private pages (Matt Westcott) ### Documentation diff --git a/wagtail/admin/templates/wagtailadmin/home/user_objects_in_workflow_moderation.html b/wagtail/admin/templates/wagtailadmin/home/user_objects_in_workflow_moderation.html index dbca2dfac7..19de8a3108 100644 --- a/wagtail/admin/templates/wagtailadmin/home/user_objects_in_workflow_moderation.html +++ b/wagtail/admin/templates/wagtailadmin/home/user_objects_in_workflow_moderation.html @@ -37,7 +37,9 @@ {% locale_label_from_id obj.locale_id as locale_label %} {% status locale_label classname="w-status--label" %} {% endif %} - {% include "wagtailadmin/pages/listing/_privacy_indicator.html" with page=obj %} + {% if is_page %} + {% include "wagtailadmin/pages/listing/_privacy_indicator.html" with page=obj %} + {% endif %} {% include "wagtailadmin/pages/listing/_locked_indicator.html" with page=obj %} diff --git a/wagtail/admin/templates/wagtailadmin/home/workflow_objects_to_moderate.html b/wagtail/admin/templates/wagtailadmin/home/workflow_objects_to_moderate.html index 05ed52a6c6..1e63ecc1cc 100644 --- a/wagtail/admin/templates/wagtailadmin/home/workflow_objects_to_moderate.html +++ b/wagtail/admin/templates/wagtailadmin/home/workflow_objects_to_moderate.html @@ -37,7 +37,9 @@ {% locale_label_from_id obj.locale_id as locale_label %} {% status locale_label classname="w-status--label" %} {% endif %} - {% include "wagtailadmin/pages/listing/_privacy_indicator.html" with page=obj %} + {% if is_page %} + {% include "wagtailadmin/pages/listing/_privacy_indicator.html" with page=obj %} + {% endif %} {% include "wagtailadmin/pages/listing/_locked_indicator.html" with page=obj %} {% if actions %} diff --git a/wagtail/admin/tests/test_workflows.py b/wagtail/admin/tests/test_workflows.py index f6050119b0..cc8dc03037 100644 --- a/wagtail/admin/tests/test_workflows.py +++ b/wagtail/admin/tests/test_workflows.py @@ -23,6 +23,7 @@ from wagtail.admin.utils import ( from wagtail.models import ( GroupApprovalTask, Page, + PageViewRestriction, Task, TaskState, Workflow, @@ -3510,3 +3511,31 @@ class TestSnippetWorkflowStatusNotLockable(TestSnippetWorkflowStatus): response = self.client.get(self.get_url("edit")) self.assertNotContains(response, needle) self.assertContains(response, "Save draft") + + +class TestDashboardWithSnippets(BaseSnippetWorkflowTests): + def setUp(self): + super().setUp() + # Ensure that the presence of private pages doesn't break the dashboard - + # https://github.com/wagtail/wagtail/issues/10819 + homepage = Page.objects.filter(depth=2).first() + PageViewRestriction.objects.create( + page=homepage, restriction_type=PageViewRestriction.LOGIN + ) + + def test_dashboard_for_submitter(self): + self.login(self.submitter) + self.post("submit") + + response = self.client.get(reverse("wagtailadmin_home")) + self.assertEqual(response.status_code, 200) + self.assertContains(response, "Your pages and snippets in a workflow") + + def test_dashboard_for_moderator(self): + self.login(self.submitter) + self.post("submit") + + self.login(self.moderator) + response = self.client.get(reverse("wagtailadmin_home")) + self.assertEqual(response.status_code, 200) + self.assertContains(response, "Awaiting your review")