From 0b3f4dc1e859e5e40ebf3f7ace9b16ecd28acfb7 Mon Sep 17 00:00:00 2001 From: Matt Westcott Date: Fri, 7 Jul 2023 18:24:24 +0100 Subject: [PATCH] Remove unused page listing templates and tags --- .../wagtailadmin/pages/listing/_list.html | 79 ------------- .../pages/listing/_list_explore.html | 1 - .../pages/listing/_table_headers_explore.html | 65 ----------- .../admin/templatetags/wagtailadmin_tags.py | 109 +----------------- 4 files changed, 1 insertion(+), 253 deletions(-) delete mode 100644 wagtail/admin/templates/wagtailadmin/pages/listing/_list.html delete mode 100644 wagtail/admin/templates/wagtailadmin/pages/listing/_list_explore.html delete mode 100644 wagtail/admin/templates/wagtailadmin/pages/listing/_table_headers_explore.html diff --git a/wagtail/admin/templates/wagtailadmin/pages/listing/_list.html b/wagtail/admin/templates/wagtailadmin/pages/listing/_list.html deleted file mode 100644 index 333299939a..0000000000 --- a/wagtail/admin/templates/wagtailadmin/pages/listing/_list.html +++ /dev/null @@ -1,79 +0,0 @@ -{% load i18n %} -{% load l10n %} -{% load wagtailadmin_tags %} - - {% if show_ordering_column or show_bulk_actions %} - - {% endif %} - - {% if show_parent %} - - {% endif %} - - - - - - {% block post_parent_page_headers %} - {% include "wagtailadmin/pages/listing/_table_headers_explore.html" %} - {% endblock %} - - - {% if pages %} - {% trans "Select page" as checkbox_aria_label %} - {% for page in pages %} - {% page_permissions page as page_perms %} - - {% if show_ordering_column %} - - {% elif show_bulk_actions %} - {% include "wagtailadmin/bulk_actions/listing_checkbox_cell.html" with obj_type="page" obj=page aria_labelledby_prefix="page_" aria_labelledby=page.pk|unlocalize aria_labelledby_suffix="_title" %} - {% endif %} - - {% if show_parent %} - - {% endif %} - - - - {% block page_navigation %} - {% include "wagtailadmin/pages/listing/_navigation_explore.html" %} - {% endblock %} - - {% endfor %} - {% else %} - {% block no_results %} - {% url 'wagtailadmin_pages:add_subpage' parent_page.id as add_page_url%} - - {% endblock %} - {% endif %} - -
- {% if orderable and ordering == "ord" %} -
- {% icon name="grip" classname="default" %} - - {% trans 'Drag' %} - Item {{ forloop.counter }} of {{ pages|length }} - -
- {% endif %} -
- {% block page_title %} - {% include "wagtailadmin/pages/listing/_page_title_explore.html" %} - {% endblock %} - - {% block page_parent_page_title %} - {% with page.get_parent as parent %} - {% if parent %} - {{ parent.specific_deferred.get_admin_display_title }} - {% endif %} - {% endwith %} - {% endblock %} - - {% if page.latest_revision_created_at %} - {% human_readable_date page.latest_revision_created_at %} - {% endif %} - {{ page.page_type_display_name }} - {% include "wagtailadmin/shared/page_status_tag.html" with page=page %} -

{% trans "No pages have been created at this location." %}{% if parent_page and parent_page_perms.can_add_subpage %} {% blocktrans trimmed %}Why not create one?{% endblocktrans %}{% endif %}

diff --git a/wagtail/admin/templates/wagtailadmin/pages/listing/_list_explore.html b/wagtail/admin/templates/wagtailadmin/pages/listing/_list_explore.html deleted file mode 100644 index 9164f86a20..0000000000 --- a/wagtail/admin/templates/wagtailadmin/pages/listing/_list_explore.html +++ /dev/null @@ -1 +0,0 @@ -{% extends "wagtailadmin/pages/listing/_list.html" %} diff --git a/wagtail/admin/templates/wagtailadmin/pages/listing/_table_headers_explore.html b/wagtail/admin/templates/wagtailadmin/pages/listing/_table_headers_explore.html deleted file mode 100644 index 28766fdad8..0000000000 --- a/wagtail/admin/templates/wagtailadmin/pages/listing/_table_headers_explore.html +++ /dev/null @@ -1,65 +0,0 @@ -{% load i18n wagtailadmin_tags %} - -{% comment %} - -Table headers for the page listing, when in 'explore' mode. Expects the following variables: - -sortable: if true, headings are links to wagtailadmin_explore with sort parameters applied. -sortable_by_type: must be true to allow sorting on the 'type' column -show_ordering_column: if true, an 'ordering' column is added. -orderable: if true, the 'ordering' column is populated (again with links to wagtailadmin_explore). - -If either sortable or orderable is true, the following variables are also required: - -parent_page: The page instance currently being browsed (used to generate the correct wagtailadmin_explore urls and title text) -ordering: the current sort parameter - -{% endcomment %} - - - {% if show_ordering_column %} - - {% if orderable %} - {% if ordering == "ord" %} - - {% icon name="order" %}{% trans 'Sort' %} - - {% else %} - - {% icon name="order" %}{% trans 'Sort' %} - - {% endif %} - {% endif %} - - {% elif show_bulk_actions %} - {% include 'wagtailadmin/bulk_actions/select_all_checkbox_cell.html' with parent=parent_page.id %} - {% endif %} - - {% trans 'Title' as title_label %} - {% page_table_header_label label=title_label sortable=sortable sort_field='title' parent_page_title=parent_page.title %} - - {% if show_parent %} - - {% trans 'Parent' as parent_label %} - {% page_table_header_label label=parent_label sortable=0 parent_page_title=parent_page.title %} - - {% endif %} - - {% trans 'Updated' as updated_label %} - {% page_table_header_label label=updated_label sortable=sortable sort_field='latest_revision_created_at' parent_page_title=parent_page.title %} - - - {% trans 'Type' as type_label %} - - {% if sortable and sortable_by_type %} - {% page_table_header_label label=type_label sortable=1 sort_field='content_type' parent_page_title=parent_page.title %} - {% else %} - {% page_table_header_label label=type_label sortable=0 parent_page_title=parent_page.title %} - {% endif %} - - - {% trans 'Status' as status_label %} - {% page_table_header_label label=status_label sortable=sortable sort_field='live' parent_page_title=parent_page.title %} - - - diff --git a/wagtail/admin/templatetags/wagtailadmin_tags.py b/wagtail/admin/templatetags/wagtailadmin_tags.py index ffb768bfbc..0b01986a3e 100644 --- a/wagtail/admin/templatetags/wagtailadmin_tags.py +++ b/wagtail/admin/templatetags/wagtailadmin_tags.py @@ -19,7 +19,7 @@ from django.urls import reverse from django.urls.exceptions import NoReverseMatch from django.utils import timezone from django.utils.encoding import force_str -from django.utils.html import avoid_wrapping, format_html, format_html_join, json_script +from django.utils.html import avoid_wrapping, json_script from django.utils.http import urlencode from django.utils.safestring import mark_safe from django.utils.timesince import timesince @@ -390,113 +390,6 @@ def querystring(context, **kwargs): return "?" + querydict.urlencode() -@register.simple_tag(takes_context=True) -def page_table_header_label(context, label=None, parent_page_title=None, **kwargs): - """ - Wraps table_header_label to add a title attribute based on the parent page title and the column label - """ - if label: - translation_context = {"parent": parent_page_title, "label": label} - ascending_title_text = ( - _( - "Sort the order of child pages within '%(parent)s' by '%(label)s' in ascending order." - ) - % translation_context - ) - descending_title_text = ( - _( - "Sort the order of child pages within '%(parent)s' by '%(label)s' in descending order." - ) - % translation_context - ) - else: - ascending_title_text = None - descending_title_text = None - - return table_header_label( - context, - label=label, - ascending_title_text=ascending_title_text, - descending_title_text=descending_title_text, - **kwargs, - ) - - -@register.simple_tag(takes_context=True) -def table_header_label( - context, - label=None, - sortable=True, - ordering=None, - sort_context_var="ordering", - sort_param="ordering", - sort_field=None, - ascending_title_text=None, - descending_title_text=None, -): - """ - A label to go in a table header cell, optionally with a 'sort' link that alternates between - forward and reverse sorting - - label = label text - ordering = current active ordering. If not specified, we will fetch it from the template context variable - given by sort_context_var. (We don't fetch it from the URL because that wouldn't give the view method - the opportunity to set a default) - sort_param = URL parameter that indicates the current active ordering - sort_field = the value for sort_param that indicates that sorting is currently on this column. - For example, if sort_param='ordering' and sort_field='title', then a URL parameter of - ordering=title indicates that the listing is ordered forwards on this column, and a URL parameter - of ordering=-title indicated that the listing is ordered in reverse on this column - ascending_title_text = title attribute to use on the link when the link action will sort in ascending order - descending_title_text = title attribute to use on the link when the link action will sort in descending order - - To disable sorting on this column, set sortable=False or leave sort_field unspecified. - """ - if not sortable or not sort_field: - # render label without a sort link - return label - - if ordering is None: - ordering = context.get(sort_context_var) - reverse_sort_field = "-%s" % sort_field - - if ordering == sort_field: - # currently ordering forwards on this column; link should change to reverse ordering - attrs = { - "href": querystring(context, **{sort_param: reverse_sort_field}), - "class": "icon icon-arrow-down-after teal", - } - if descending_title_text is not None: - attrs["title"] = descending_title_text - - elif ordering == reverse_sort_field: - # currently ordering backwards on this column; link should change to forward ordering - attrs = { - "href": querystring(context, **{sort_param: sort_field}), - "class": "icon icon-arrow-up-after teal", - } - if ascending_title_text is not None: - attrs["title"] = ascending_title_text - - else: - # not currently ordering on this column; link should change to forward ordering - attrs = { - "href": querystring(context, **{sort_param: sort_field}), - "class": "icon icon-arrow-down-after", - } - if ascending_title_text is not None: - attrs["title"] = ascending_title_text - - attrs_string = format_html_join(" ", '{}="{}"', attrs.items()) - - return format_html( - # need whitespace around label for correct positioning of arrow icon - " {label} ", - attrs=attrs_string, - label=label, - ) - - @register.simple_tag(takes_context=True) def pagination_querystring(context, page_number, page_key="p"): """