Fix issue where collection deletion success message was not correct

- Fixes #10813
pull/10823/head
LB Johnston 2023-08-24 07:40:04 +10:00 zatwierdzone przez LB (Ben Johnston)
rodzic 2be1da6621
commit 6f9dda5cfc
4 zmienionych plików z 9 dodań i 1 usunięć

Wyświetl plik

@ -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)

Wyświetl plik

@ -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

Wyświetl plik

@ -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)

Wyświetl plik

@ -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)