kopia lustrzana https://github.com/wagtail/wagtail
Ensure 'next' param on image / doc listings always links back to index page, not results view
Fixes #8291. When results listings are generated as partial AJAX responses through the listing_results review, the 'next' parameter on those results should point back to the main 'index' view so that on return from the edit view, the user gets back a full page rather than a partial response.pull/8328/head
rodzic
13b60a2688
commit
7ad87c7d93
|
@ -137,6 +137,25 @@ class TestDocumentIndexView(TestCase, WagtailTestUtils):
|
|||
self.assertContains(response, "%s?next=%s" % (edit_url, next_url))
|
||||
|
||||
|
||||
class TestDocumentListingResultsView(TestCase, WagtailTestUtils):
|
||||
def setUp(self):
|
||||
self.login()
|
||||
|
||||
def get(self, params={}):
|
||||
return self.client.get(reverse("wagtaildocs:listing_results"), params)
|
||||
|
||||
def test_search(self):
|
||||
doc = models.Document.objects.create(title="A boring report")
|
||||
|
||||
response = self.get({"q": "boring"})
|
||||
self.assertEqual(response.status_code, 200)
|
||||
# 'next' param on edit page link should point back to the documents index, not the results view
|
||||
self.assertContains(
|
||||
response,
|
||||
"/admin/documents/edit/%d/?next=/admin/documents/%%3Fq%%3Dboring" % doc.id,
|
||||
)
|
||||
|
||||
|
||||
class TestDocumentAddView(TestCase, WagtailTestUtils):
|
||||
def setUp(self):
|
||||
self.login()
|
||||
|
|
|
@ -71,13 +71,18 @@ class BaseListingView(TemplateView):
|
|||
paginator = Paginator(documents, per_page=20)
|
||||
documents = paginator.get_page(self.request.GET.get("p"))
|
||||
|
||||
next_url = reverse("wagtaildocs:index")
|
||||
request_query_string = self.request.META.get("QUERY_STRING")
|
||||
if request_query_string:
|
||||
next_url += "?" + request_query_string
|
||||
|
||||
context.update(
|
||||
{
|
||||
"ordering": ordering,
|
||||
"documents": documents,
|
||||
"query_string": query_string,
|
||||
"is_searching": bool(query_string),
|
||||
"next": self.request.get_full_path(),
|
||||
"next": next_url,
|
||||
}
|
||||
)
|
||||
return context
|
||||
|
|
|
@ -194,6 +194,28 @@ class TestImageIndexView(TestCase, WagtailTestUtils):
|
|||
)
|
||||
|
||||
|
||||
class TestImageListingResultsView(TestCase, WagtailTestUtils):
|
||||
def setUp(self):
|
||||
self.login()
|
||||
|
||||
def get(self, params={}):
|
||||
return self.client.get(reverse("wagtailimages:listing_results"), params)
|
||||
|
||||
def test_search(self):
|
||||
monster = Image.objects.create(
|
||||
title="A scary monster",
|
||||
file=get_test_image_file(),
|
||||
)
|
||||
|
||||
response = self.get({"q": "monster"})
|
||||
self.assertEqual(response.status_code, 200)
|
||||
# 'next' param on edit page link should point back to the images index, not the results view
|
||||
self.assertContains(
|
||||
response,
|
||||
"/admin/images/%d/?next=/admin/images/%%3Fq%%3Dmonster" % monster.id,
|
||||
)
|
||||
|
||||
|
||||
class TestImageAddView(TestCase, WagtailTestUtils):
|
||||
def setUp(self):
|
||||
self.login()
|
||||
|
|
|
@ -82,12 +82,17 @@ class BaseListingView(TemplateView):
|
|||
paginator = Paginator(images, per_page=INDEX_PAGE_SIZE)
|
||||
images = paginator.get_page(self.request.GET.get("p"))
|
||||
|
||||
next_url = reverse("wagtailimages:index")
|
||||
request_query_string = self.request.META.get("QUERY_STRING")
|
||||
if request_query_string:
|
||||
next_url += "?" + request_query_string
|
||||
|
||||
context.update(
|
||||
{
|
||||
"images": images,
|
||||
"query_string": query_string,
|
||||
"is_searching": bool(query_string),
|
||||
"next": self.request.get_full_path(),
|
||||
"next": next_url,
|
||||
}
|
||||
)
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue