kopia lustrzana https://github.com/wagtail/wagtail
Add pagination information to page title column header
rodzic
d4eb1ec5a3
commit
53c6bf0690
|
@ -0,0 +1,7 @@
|
|||
{% extends "wagtailadmin/tables/column_header.html" %}
|
||||
|
||||
{% block after_label %}
|
||||
{% if page_obj %}
|
||||
{{ page_obj.start_index }}-{{ page_obj.end_index }} of {{ page_obj.paginator.count }}
|
||||
{% endif %}
|
||||
{% endblock %}
|
|
@ -17,4 +17,5 @@
|
|||
{% else %}
|
||||
{{ column.label }}
|
||||
{% endif %}
|
||||
{% block after_label %}{% endblock %}
|
||||
</th>
|
||||
|
|
|
@ -59,6 +59,7 @@ class TestPageExplorer(WagtailTestUtils, TestCase):
|
|||
self.assertEqual(
|
||||
page_ids, [self.new_page.id, self.old_page.id, self.child_page.id]
|
||||
)
|
||||
self.assertContains(response, "1-3 of 3")
|
||||
|
||||
def test_explore_root(self):
|
||||
response = self.client.get(reverse("wagtailadmin_explore_root"))
|
||||
|
@ -250,6 +251,7 @@ class TestPageExplorer(WagtailTestUtils, TestCase):
|
|||
|
||||
# Check that we got the correct page
|
||||
self.assertEqual(response.context["page_obj"].number, 2)
|
||||
self.assertContains(response, "51-100 of 153")
|
||||
|
||||
def test_pagination_invalid(self):
|
||||
self.make_pages()
|
||||
|
@ -412,6 +414,7 @@ class TestPageExplorer(WagtailTestUtils, TestCase):
|
|||
|
||||
page_ids = [page.id for page in response.context["pages"]]
|
||||
self.assertEqual(page_ids, [self.old_page.id])
|
||||
self.assertContains(response, "1-1 of 1")
|
||||
|
||||
def test_search_searches_descendants(self):
|
||||
response = self.client.get(reverse("wagtailadmin_explore_root"), {"q": "old"})
|
||||
|
|
|
@ -5,9 +5,15 @@ from wagtail.admin.ui.tables import BaseColumn, BulkActionsCheckboxColumn, Colum
|
|||
|
||||
|
||||
class PageTitleColumn(BaseColumn):
|
||||
header_template_name = "wagtailadmin/pages/listing/_page_title_column_header.html"
|
||||
cell_template_name = "wagtailadmin/pages/listing/_page_title_cell.html"
|
||||
classname = "title"
|
||||
|
||||
def get_header_context_data(self, parent_context):
|
||||
context = super().get_header_context_data(parent_context)
|
||||
context["page_obj"] = parent_context.get("page_obj")
|
||||
return context
|
||||
|
||||
def get_cell_context_data(self, instance, parent_context):
|
||||
context = super().get_cell_context_data(instance, parent_context)
|
||||
context["page_perms"] = instance.permissions_for_user(
|
||||
|
@ -132,4 +138,5 @@ class PageTable(Table):
|
|||
context = super().get_context_data(parent_context)
|
||||
context["show_locale_labels"] = self.show_locale_labels
|
||||
context["perms"] = parent_context.get("perms")
|
||||
context["page_obj"] = parent_context.get("page_obj")
|
||||
return context
|
||||
|
|
Ładowanie…
Reference in New Issue