From b1a3a292f7503bf36bf19971813e6714ce07a24b Mon Sep 17 00:00:00 2001 From: Matt Westcott Date: Mon, 14 Jun 2021 13:54:28 +0100 Subject: [PATCH] Refactor images index into CBV and eliminate is_ajax (#7251) * Convert images index to a class-based view * Use TemplateView for images index * Add a separate URL endpoint for image search results include Eliminates use of request.is_ajax, along with some unnecessary collection querying --- wagtail/images/admin_urls.py | 3 +- .../templates/wagtailimages/images/index.html | 2 +- wagtail/images/views/images.py | 120 ++++++++++-------- 3 files changed, 69 insertions(+), 56 deletions(-) diff --git a/wagtail/images/admin_urls.py b/wagtail/images/admin_urls.py index c3ebf9fc25..6a11fa5b2e 100644 --- a/wagtail/images/admin_urls.py +++ b/wagtail/images/admin_urls.py @@ -5,7 +5,8 @@ from wagtail.images.views import chooser, images, multiple app_name = 'wagtailimages' urlpatterns = [ - path('', images.index, name='index'), + path('', images.IndexView.as_view(), name='index'), + path('results/', images.ListingResultsView.as_view(), name='listing_results'), path('/', images.edit, name='edit'), path('/delete/', images.delete, name='delete'), path('/generate_url/', images.url_generator, name='url_generator'), diff --git a/wagtail/images/templates/wagtailimages/images/index.html b/wagtail/images/templates/wagtailimages/images/index.html index 8b3b04d9dc..8258963c0b 100644 --- a/wagtail/images/templates/wagtailimages/images/index.html +++ b/wagtail/images/templates/wagtailimages/images/index.html @@ -8,7 +8,7 @@ {{ block.super }}