kopia lustrzana https://github.com/wagtail/wagtail
Ensure that explorer_results views fill in the correct next_url parameter on action URLs
Fixes #11177, by adding the option to pass an actions_next_url argument to the table as per https://github.com/wagtail/wagtail/pull/11175#discussion_r1381892130pull/11191/head
rodzic
d737f29a62
commit
582fe12749
|
@ -33,6 +33,7 @@ Changelog
|
|||
* Fix: Remove search logging from project template so that new projects without the search promotions module will not error (Matt Westcott)
|
||||
* Fix: Ensure text only email notifications for updated comments do not escape HTML characters (Rohit Sharma)
|
||||
* Fix: Use logical OR operator to combine search fields for Django ORM in generic IndexView (Varun Kumar)
|
||||
* Fix: Ensure that explorer_results views fill in the correct next_url parameter on action URLs (Matt Westcott)
|
||||
* Docs: Fix code example for `{% picture ... as ... %}` template tag (Rezyapkin)
|
||||
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@ depth: 1
|
|||
* Remove search logging from project template so that new projects without the search promotions module will not error (Matt Westcott)
|
||||
* Ensure text only email notifications for updated comments do not escape HTML characters (Rohit Sharma)
|
||||
* Use logical OR operator to combine search fields for Django ORM in generic IndexView (Varun Kumar)
|
||||
* Ensure that explorer_results views fill in the correct next_url parameter on action URLs (Matt Westcott)
|
||||
|
||||
### Documentation
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{% load l10n %}
|
||||
<td id="page_{{ instance.pk|unlocalize }}_title" {% if column.classname %}class="{{ column.classname }}"{% endif %} data-listing-page-title>
|
||||
{% include "wagtailadmin/pages/listing/_page_title_explore.html" with page=instance show_locale_labels=show_locale_labels %}
|
||||
{% include "wagtailadmin/pages/listing/_page_title_explore.html" with page=instance show_locale_labels=show_locale_labels actions_next_url=actions_next_url %}
|
||||
{% if parent_page %}
|
||||
<div>
|
||||
<a href="{% url 'wagtailadmin_explore' parent_page.id %}" class="icon icon-arrow-right">{{ parent_page.get_admin_display_title }}</a>
|
||||
|
|
|
@ -28,5 +28,5 @@
|
|||
</div>
|
||||
|
||||
<ul class="actions">
|
||||
{% page_listing_buttons page request.user %}
|
||||
{% page_listing_buttons page request.user next_url=actions_next_url %}
|
||||
</ul>
|
||||
|
|
|
@ -444,8 +444,8 @@ def paginate(context, page, base_url="", page_key="p", classname=""):
|
|||
|
||||
|
||||
@register.inclusion_tag("wagtailadmin/shared/buttons.html", takes_context=True)
|
||||
def page_listing_buttons(context, page, user):
|
||||
next_url = context["request"].path
|
||||
def page_listing_buttons(context, page, user, next_url=None):
|
||||
next_url = next_url or context["request"].path
|
||||
button_hooks = hooks.get_hooks("register_page_listing_buttons")
|
||||
|
||||
buttons = []
|
||||
|
|
|
@ -3,6 +3,7 @@ from django.contrib.contenttypes.models import ContentType
|
|||
from django.core import paginator
|
||||
from django.test import TestCase, override_settings
|
||||
from django.urls import reverse
|
||||
from django.utils.http import urlencode
|
||||
|
||||
from wagtail import hooks
|
||||
from wagtail.admin.widgets import Button
|
||||
|
@ -46,9 +47,8 @@ class TestPageExplorer(WagtailTestUtils, TestCase):
|
|||
self.user = self.login()
|
||||
|
||||
def test_explore(self):
|
||||
response = self.client.get(
|
||||
reverse("wagtailadmin_explore", args=(self.root_page.id,))
|
||||
)
|
||||
explore_url = reverse("wagtailadmin_explore", args=(self.root_page.id,))
|
||||
response = self.client.get(explore_url)
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertTemplateUsed(response, "wagtailadmin/pages/index.html")
|
||||
self.assertEqual(self.root_page, response.context["parent_page"])
|
||||
|
@ -59,6 +59,38 @@ class TestPageExplorer(WagtailTestUtils, TestCase):
|
|||
self.assertEqual(
|
||||
page_ids, [self.new_page.id, self.old_page.id, self.child_page.id]
|
||||
)
|
||||
expected_new_page_copy_url = (
|
||||
reverse("wagtailadmin_pages:copy", args=(self.new_page.id,))
|
||||
+ "?"
|
||||
+ urlencode({"next": explore_url})
|
||||
)
|
||||
self.assertContains(response, f'href="{expected_new_page_copy_url}"')
|
||||
|
||||
self.assertContains(response, "1-3 of 3")
|
||||
|
||||
def test_explore_results(self):
|
||||
explore_results_url = reverse(
|
||||
"wagtailadmin_explore_results", args=(self.root_page.id,)
|
||||
)
|
||||
response = self.client.get(explore_results_url)
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertTemplateUsed(response, "wagtailadmin/pages/index_results.html")
|
||||
self.assertEqual(self.root_page, response.context["parent_page"])
|
||||
|
||||
page_ids = [page.id for page in response.context["pages"]]
|
||||
self.assertEqual(
|
||||
page_ids, [self.new_page.id, self.old_page.id, self.child_page.id]
|
||||
)
|
||||
# the 'next' parameter should return to the explore view, NOT
|
||||
# the partial explore_results view
|
||||
explore_url = reverse("wagtailadmin_explore", args=(self.root_page.id,))
|
||||
expected_new_page_copy_url = (
|
||||
reverse("wagtailadmin_pages:copy", args=(self.new_page.id,))
|
||||
+ "?"
|
||||
+ urlencode({"next": explore_url})
|
||||
)
|
||||
self.assertContains(response, f'href="{expected_new_page_copy_url}"')
|
||||
|
||||
self.assertContains(response, "1-3 of 3")
|
||||
|
||||
def test_explore_root(self):
|
||||
|
|
|
@ -27,6 +27,7 @@ class PageTitleColumn(BaseColumn):
|
|||
context["parent_page"] = getattr(instance, "annotated_parent_page", None)
|
||||
context["show_locale_labels"] = parent_context.get("show_locale_labels")
|
||||
context["perms"] = parent_context.get("perms")
|
||||
context["actions_next_url"] = parent_context.get("actions_next_url")
|
||||
return context
|
||||
|
||||
|
||||
|
@ -90,6 +91,7 @@ class PageTable(Table):
|
|||
use_row_ordering_attributes=False,
|
||||
parent_page=None,
|
||||
show_locale_labels=False,
|
||||
actions_next_url=None,
|
||||
**kwargs,
|
||||
):
|
||||
super().__init__(*args, **kwargs)
|
||||
|
@ -114,6 +116,7 @@ class PageTable(Table):
|
|||
)
|
||||
|
||||
self.show_locale_labels = show_locale_labels
|
||||
self.actions_next_url = actions_next_url
|
||||
|
||||
def get_ascending_title_text(self, column):
|
||||
return self.ascending_title_text_format % {
|
||||
|
@ -150,4 +153,7 @@ class PageTable(Table):
|
|||
context["is_searching_whole_tree"] = parent_context.get(
|
||||
"is_searching_whole_tree"
|
||||
)
|
||||
context["actions_next_url"] = (
|
||||
self.actions_next_url or parent_context.get("request").path
|
||||
)
|
||||
return context
|
||||
|
|
|
@ -232,6 +232,7 @@ class BaseIndexView(PermissionCheckedMixin, BaseListingView):
|
|||
kwargs["use_row_ordering_attributes"] = self.show_ordering_column
|
||||
kwargs["parent_page"] = self.parent_page
|
||||
kwargs["show_locale_labels"] = self.i18n_enabled and self.parent_page.is_root()
|
||||
kwargs["actions_next_url"] = self.get_index_url()
|
||||
|
||||
if self.show_ordering_column:
|
||||
kwargs["attrs"] = {
|
||||
|
|
Ładowanie…
Reference in New Issue