0
0
mirror of https://github.com/wagtail/wagtail.git synced 2024-12-01 11:41:20 +01:00

Reinstate default_ordering to search promotions IndexView

This commit is contained in:
Sage Abdullah 2024-02-29 17:28:56 +00:00
parent 1a7230ea21
commit 93c4a89b33
No known key found for this signature in database
GPG Key ID: EB1A33CC51CC0217
2 changed files with 9 additions and 0 deletions

View File

@ -296,6 +296,13 @@ class TestSearchPromotionsIndexView(WagtailTestUtils, TestCase):
sort_order=0,
description="ooh, it's a snake",
)
# Add another one to make sure it's not ordered descending by pk
SearchPromotion.objects.create(
query=Query.get("beloved snake"),
page_id=1,
sort_order=0,
description="beloved snake goes ssSSSS",
)
response = self.client.get(reverse("wagtailsearchpromotions:index"))
@ -305,6 +312,7 @@ class TestSearchPromotionsIndexView(WagtailTestUtils, TestCase):
# "aargh snake" should be the first result alphabetically
self.assertEqual(response.context["queries"][0].query_string, "aaargh snake")
self.assertEqual(response.context["queries"][1].query_string, "beloved snake")
def test_multiple_searchpromotions(self):
today = date.today()

View File

@ -38,6 +38,7 @@ class IndexView(generic.IndexView):
index_results_url_name = "wagtailsearchpromotions:index_results"
_show_breadcrumbs = True
search_fields = ["query_string"]
default_ordering = "query_string"
add_url_name = "wagtailsearchpromotions:add"
add_item_label = gettext_lazy("Add new promoted result")
columns = [