From 8735472acefee57cc260d9b3ad8b4a0a1b598465 Mon Sep 17 00:00:00 2001 From: Matt Westcott Date: Mon, 20 Jun 2022 23:31:12 +0100 Subject: [PATCH] Move locale chooser into filter_form Remove the hidden 'locale' field, as it's not clear why it's needed - there's no UI mechanism for reverting back to the locale we initially opened the modal on, so there's no reason to persist it between modal view loads. --- .../wagtailsnippets/chooser/choose.html | 20 +------ wagtail/snippets/tests.py | 13 +++-- wagtail/snippets/views/chooser.py | 57 +++++++------------ 3 files changed, 30 insertions(+), 60 deletions(-) diff --git a/wagtail/snippets/templates/wagtailsnippets/chooser/choose.html b/wagtail/snippets/templates/wagtailsnippets/chooser/choose.html index a60d0629ea..149638e206 100644 --- a/wagtail/snippets/templates/wagtailsnippets/chooser/choose.html +++ b/wagtail/snippets/templates/wagtailsnippets/chooser/choose.html @@ -3,16 +3,12 @@ {% include "wagtailadmin/shared/header.html" with title=choose_str subtitle=model_opts.verbose_name icon="snippet" %}
- {% if filter_form.fields or locale or locale_options %} + {% if filter_form.fields %} {% endif %} diff --git a/wagtail/snippets/tests.py b/wagtail/snippets/tests.py index 5b5fee262a..7916c86995 100644 --- a/wagtail/snippets/tests.py +++ b/wagtail/snippets/tests.py @@ -1763,7 +1763,8 @@ class TestSnippetChoose(TestCase, WagtailTestUtils): self.assertTemplateUsed(response, "wagtailsnippets/chooser/choose.html") def test_not_searchable(self): - self.assertFalse(self.get().context["is_searchable"]) + # filter_form should not have a search field + self.assertFalse(self.get().context["filter_form"].fields.get("q")) @override_settings(WAGTAIL_I18N_ENABLED=True) def test_filter_by_locale(self): @@ -1776,10 +1777,9 @@ class TestSnippetChoose(TestCase, WagtailTestUtils): response = self.get() # Check the filter is added - self.assertIn( - '