Preserve URL parameters on parent link in page chooser search results

Fixes #11955
pull/12643/head
Matt Westcott 2024-11-30 04:13:01 +00:00 zatwierdzone przez Sage Abdullah
rodzic 28cde800d9
commit 8cdeb23a43
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: EB1A33CC51CC0217
2 zmienionych plików z 12 dodań i 2 usunięć

Wyświetl plik

@ -1,7 +1,7 @@
{% load wagtailadmin_tags %}
<td {% if column.classname %}class="{{ column.classname }}"{% endif %}>
{% if value %}
<a href="{% url 'wagtailadmin_choose_page_child' value.id %}" class="navigate-parent">{{ value.get_admin_display_title }}</a>
<a href="{% url 'wagtailadmin_choose_page_child' value.id %}{% querystring p=None q=None %}" class="navigate-parent">{{ value.get_admin_display_title }}</a>
{% if show_locale_labels %}{% status value.locale.get_display_name classname="w-status--label" %}{% endif %}
{% endif %}
</td>

Wyświetl plik

@ -371,12 +371,22 @@ class TestChooserSearch(WagtailTestUtils, TransactionTestCase):
return self.client.get(reverse("wagtailadmin_choose_page_search"), params or {})
def test_simple(self):
response = self.get({"q": "foobarbaz"})
response = self.get({"q": "foobarbaz", "allow_external_link": "true"})
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, "wagtailadmin/chooser/_search_results.html")
self.assertContains(response, "There is 1 match")
self.assertContains(response, "foobarbaz")
# parent page link should preserve the allow_external_link parameter
expected_url = (
reverse("wagtailadmin_choose_page_child", args=[self.root_page.id])
+ "?allow_external_link=true"
)
self.assertContains(
response,
f'<a href="{expected_url}" class="navigate-parent">{self.root_page.title}</a>',
)
def test_partial_match(self):
response = self.get({"q": "fooba"})
self.assertEqual(response.status_code, 200)