diff --git a/CHANGELOG.txt b/CHANGELOG.txt index a57a707a9c..5413db097e 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -16,6 +16,7 @@ Changelog * 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) + * Fix: When deleting collections, ensure the collection name is correctly shown in the success message (LB (Ben) Johnston) * 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 5076aae4af..46eb9ecba4 100644 --- a/docs/releases/5.2.md +++ b/docs/releases/5.2.md @@ -29,6 +29,7 @@ depth: 1 * 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) + * When deleting collections, ensure the collection name is correctly shown in the success message (LB (Ben) Johnston) ### Documentation diff --git a/wagtail/admin/tests/test_collections_views.py b/wagtail/admin/tests/test_collections_views.py index 28684a6ec4..cb08bd0ba0 100644 --- a/wagtail/admin/tests/test_collections_views.py +++ b/wagtail/admin/tests/test_collections_views.py @@ -600,6 +600,12 @@ class TestDeleteCollectionAsSuperuser(WagtailTestUtils, TestCase): # Should redirect back to index self.assertRedirects(response, reverse("wagtailadmin_collections:index")) + # Check the message content + self.assertEqual( + response.context["message"], + "Collection 'Holiday snaps' deleted.", + ) + # Check that the collection was deleted with self.assertRaises(Collection.DoesNotExist): Collection.objects.get(id=self.collection.id) diff --git a/wagtail/admin/views/collections.py b/wagtail/admin/views/collections.py index 83434175fa..6472a6f5cf 100644 --- a/wagtail/admin/views/collections.py +++ b/wagtail/admin/views/collections.py @@ -182,6 +182,6 @@ class Delete(DeleteView): # collection is non-empty; refuse to delete it return HttpResponseForbidden() + messages.success(request, self.get_success_message()) self.object.delete() - messages.success(request, self.success_message.format(self.object)) return redirect(self.index_url_name)