From 89ed36c38cebd36553f1a67a4bc2aa6141067683 Mon Sep 17 00:00:00 2001 From: Sage Abdullah Date: Thu, 29 Feb 2024 12:43:47 +0000 Subject: [PATCH] Use breadcrumbs and new header button for documents listing view --- wagtail/documents/tests/test_admin_views.py | 2 +- wagtail/documents/views/documents.py | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/wagtail/documents/tests/test_admin_views.py b/wagtail/documents/tests/test_admin_views.py index 471a33494f..7314fe16a4 100644 --- a/wagtail/documents/tests/test_admin_views.py +++ b/wagtail/documents/tests/test_admin_views.py @@ -169,7 +169,7 @@ class TestDocumentIndexView(WagtailTestUtils, TestCase): def test_search_form_rendered(self): response = self.get() html = response.content.decode() - search_url = reverse("wagtaildocs:index") + search_url = reverse("wagtaildocs:index_results") # Search form in the header should be rendered. self.assertTagInHTML( diff --git a/wagtail/documents/views/documents.py b/wagtail/documents/views/documents.py index 2d8d0c3b10..f44b3a9e11 100644 --- a/wagtail/documents/views/documents.py +++ b/wagtail/documents/views/documents.py @@ -68,6 +68,7 @@ class IndexView(generic.IndexView): model = get_document_model() add_item_label = gettext_lazy("Add a document") show_other_searches = True + _show_breadcrumbs = True def get_base_queryset(self): # Get documents (filtered by user permission) @@ -130,10 +131,10 @@ class IndexView(generic.IndexView): return next_url def get_add_url(self): - # Pass the query string so that the collection filter is preserved + # Pass the collection filter to prefill the add form's collection field return set_query_params( super().get_add_url(), - self.request.GET.copy(), + {"collection_id": self.current_collection and self.current_collection.pk}, ) def get_edit_url(self, instance):