Use a separate results template for non-page reports

This brings us one step closer to the generic BaseListingView and its
template.

Pagination is now rendered via the base listing_results.html template.
Technically we can remove the {% if object_list %} since the check is
already done outside of the results block in that base template.
However, leave it out for now so Git correctly detects that the files
are just renamed for now.

Also, only do this for views that extend the base ReportView and
base_report.html template for now. We'll do the same for PageReportView
and base_page_report.html later, since the template for that one is
a bit different (especially around which blocks are named listing vs
results...)
pull/11987/head
Sage Abdullah 2024-05-21 16:53:22 +01:00
rodzic 3a2a362c6d
commit 38dcd6506f
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: EB1A33CC51CC0217
14 zmienionych plików z 157 dodań i 138 usunięć

Wyświetl plik

@ -8,6 +8,7 @@
{% block listing %} {% block listing %}
{% include "wagtailadmin/reports/listing/_list_page_report.html" %} {% include "wagtailadmin/reports/listing/_list_page_report.html" %}
{% endblock %} {% endblock %}
{% paginate pages base_url=request.path %}
{% else %} {% else %}
{% block no_results %} {% block no_results %}
<p>{% trans "No pages match this report's criteria." %}</p> <p>{% trans "No pages match this report's criteria." %}</p>

Wyświetl plik

@ -16,10 +16,8 @@
<div class="report{% if filters %} filterable{% endif %}"> <div class="report{% if filters %} filterable{% endif %}">
<div class="report__results"> <div class="report__results">
{% block results %} {% block results %}
{% include view.results_template_name|default:"wagtailadmin/reports/base_report_results.html" %}
{% endblock %} {% endblock %}
{% if page_obj %}
{% paginate page_obj base_url=request.path %}
{% endif %}
</div> </div>
{% if filters %} {% if filters %}
{% include "wagtailadmin/shared/filters.html" %} {% include "wagtailadmin/shared/filters.html" %}

Wyświetl plik

@ -0,0 +1 @@
{% extends "wagtailadmin/generic/listing_results.html" %}

Wyświetl plik

@ -1,10 +1,12 @@
{% extends "wagtailadmin/reports/base_report.html" %} {% extends "wagtailadmin/reports/base_report_results.html" %}
{% load i18n wagtailadmin_tags %} {% load i18n wagtailadmin_tags %}
{% block results %} {% block results %}
{% if object_list %} {% if object_list %}
{% include "wagtailadmin/reports/listing/_list_page_types_usage.html" with page_types=object_list %} {% include "wagtailadmin/reports/listing/_list_page_types_usage.html" with page_types=object_list %}
{% else %}
<p>{% trans "No page types found." %}</p>
{% endif %} {% endif %}
{% endblock %} {% endblock %}
{% block no_results_message %}
<p>{% trans "No page types found." %}</p>
{% endblock %}

Wyświetl plik

@ -1,4 +1,4 @@
{% extends 'wagtailadmin/reports/base_report.html' %} {% extends 'wagtailadmin/reports/base_report_results.html' %}
{% load i18n wagtailadmin_tags %} {% load i18n wagtailadmin_tags %}
{% block results %} {% block results %}
@ -47,7 +47,9 @@
{% endfor %} {% endfor %}
</tbody> </tbody>
</table> </table>
{% else %}
<p>{% trans "No log entries found." %}</p>
{% endif %} {% endif %}
{% endblock %} {% endblock %}
{% block no_results_message %}
<p>{% trans "No log entries found." %}</p>
{% endblock %}

Wyświetl plik

@ -7,75 +7,3 @@
</div> </div>
{{ block.super }} {{ block.super }}
{% endblock %} {% endblock %}
{% block results %}
{% if object_list %}
<table class="listing">
<thead>
<tr>
<th>
{% trans 'Workflow' %}
</th>
<th>
{% trans 'Page/Snippet' %}
</th>
<th>
{% trans 'Status' %}
</th>
<th>
{% trans 'Tasks' %}
</th>
<th>
{% trans 'Requested by' %}
</th>
<th>
{% trans 'Started at' %}
</th>
</tr>
</thead>
<tbody>
{% for workflow_state in object_list %}
<tr>
<td>
<b>{{ workflow_state.workflow }}</b>
</td>
<td>
<a href="{% admin_edit_url workflow_state.content_object %}">
{% latest_str workflow_state.content_object %}
</a>
{% i18n_enabled as show_locale_labels %}
{% if show_locale_labels and workflow_state.content_object.locale_id %}
{% locale_label_from_id workflow_state.content_object.locale_id as locale_label %}
{% status locale_label classname="w-status--label" %}
{% endif %}
</td>
<td>
{% admin_url_name workflow_state.content_object 'workflow_history_detail' as workflow_history_detail_url_name %}
{% url workflow_history_detail_url_name workflow_state.content_object.pk|admin_urlquote workflow_state.pk as status_url %}
{% status workflow_state.get_status_display url=status_url classname="w-status--primary" %}
</td>
<td>
<h2>{{ workflow_name }}</h2>
{% trans 'Incomplete task' as incomplete_title %}
{% for task in workflow_state.all_tasks_with_status %}
<span data-controller="w-tooltip" data-w-tooltip-content-value="{{ task.name }}: {{ task.status_display }}">
{% if task.status == 'approved' %}
{% icon "success" title=task.status_display classname="initial" %}
{% elif task.status == 'rejected' %}
{% icon "error" title=task.status_display classname="initial" %}
{% else %}
{% icon "radio-empty" title=incomplete_title classname="initial" %}
{% endif %}
</span>
{% endfor %}
</td>
<td>{{ workflow_state.requested_by|user_display_name }}</td>
<td>{{ workflow_state.created_at }}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% else %}
<p>{% trans "No pages/snippets have been submitted for moderation yet" %}</p>
{% endif %}
{% endblock %}

Wyświetl plik

@ -0,0 +1,76 @@
{% extends 'wagtailadmin/reports/base_report_results.html' %}
{% load i18n wagtailadmin_tags %}
{% block results %}
{% if object_list %}
<table class="listing">
<thead>
<tr>
<th>
{% trans 'Workflow' %}
</th>
<th>
{% trans 'Page/Snippet' %}
</th>
<th>
{% trans 'Status' %}
</th>
<th>
{% trans 'Tasks' %}
</th>
<th>
{% trans 'Requested by' %}
</th>
<th>
{% trans 'Started at' %}
</th>
</tr>
</thead>
<tbody>
{% for workflow_state in object_list %}
<tr>
<td>
<b>{{ workflow_state.workflow }}</b>
</td>
<td>
<a href="{% admin_edit_url workflow_state.content_object %}">
{% latest_str workflow_state.content_object %}
</a>
{% i18n_enabled as show_locale_labels %}
{% if show_locale_labels and workflow_state.content_object.locale_id %}
{% locale_label_from_id workflow_state.content_object.locale_id as locale_label %}
{% status locale_label classname="w-status--label" %}
{% endif %}
</td>
<td>
{% admin_url_name workflow_state.content_object 'workflow_history_detail' as workflow_history_detail_url_name %}
{% url workflow_history_detail_url_name workflow_state.content_object.pk|admin_urlquote workflow_state.pk as status_url %}
{% status workflow_state.get_status_display url=status_url classname="w-status--primary" %}
</td>
<td>
<h2>{{ workflow_name }}</h2>
{% trans 'Incomplete task' as incomplete_title %}
{% for task in workflow_state.all_tasks_with_status %}
<span data-controller="w-tooltip" data-w-tooltip-content-value="{{ task.name }}: {{ task.status_display }}">
{% if task.status == 'approved' %}
{% icon "success" title=task.status_display classname="initial" %}
{% elif task.status == 'rejected' %}
{% icon "error" title=task.status_display classname="initial" %}
{% else %}
{% icon "radio-empty" title=incomplete_title classname="initial" %}
{% endif %}
</span>
{% endfor %}
</td>
<td>{{ workflow_state.requested_by|user_display_name }}</td>
<td>{{ workflow_state.created_at }}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endif %}
{% endblock %}
{% block no_results_message %}
<p>{% trans "No pages/snippets have been submitted for moderation yet" %}</p>
{% endblock %}

Wyświetl plik

@ -7,57 +7,3 @@
</div> </div>
{{ block.super }} {{ block.super }}
{% endblock %} {% endblock %}
{% block results %}
{% if object_list %}
<table class="listing">
<thead>
<tr>
<th>
{% trans 'Task' %}
</th>
<th>
{% trans 'Page/Snippet' %}
</th>
<th>
{% trans 'Status' %}
</th>
<th>
{% trans 'Started at' %}
</th>
<th>
{% trans 'Completed at' %}
</th>
</tr>
</thead>
<tbody>
{% for task_state in object_list %}
<tr>
<td>
<b>{{ task_state.task }}</b>
</td>
<td>
{% with task_state.workflow_state.content_object as object %}
<a href="{% admin_edit_url object %}">
{% latest_str object %}
</a>
{% i18n_enabled as show_locale_labels %}
{% if show_locale_labels and object.locale_id %}
{% locale_label_from_id object.locale_id as locale_label %}
{% status locale_label classname="w-status--label" %}
{% endif %}
{% endwith %}
</td>
<td>
{% status task_state.get_status_display classname="w-status--primary" %}
</td>
<td>{{ task_state.started_at }}</td>
<td>{{ task_state.finished_at }}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% else %}
<p>{% trans "No pages/snippets have been submitted for moderation yet" %}</p>
{% endif %}
{% endblock %}

Wyświetl plik

@ -0,0 +1,58 @@
{% extends 'wagtailadmin/reports/base_report_results.html' %}
{% load i18n wagtailadmin_tags %}
{% block results %}
{% if object_list %}
<table class="listing">
<thead>
<tr>
<th>
{% trans 'Task' %}
</th>
<th>
{% trans 'Page/Snippet' %}
</th>
<th>
{% trans 'Status' %}
</th>
<th>
{% trans 'Started at' %}
</th>
<th>
{% trans 'Completed at' %}
</th>
</tr>
</thead>
<tbody>
{% for task_state in object_list %}
<tr>
<td>
<b>{{ task_state.task }}</b>
</td>
<td>
{% with task_state.workflow_state.content_object as object %}
<a href="{% admin_edit_url object %}">
{% latest_str object %}
</a>
{% i18n_enabled as show_locale_labels %}
{% if show_locale_labels and object.locale_id %}
{% locale_label_from_id object.locale_id as locale_label %}
{% status locale_label classname="w-status--label" %}
{% endif %}
{% endwith %}
</td>
<td>
{% status task_state.get_status_display classname="w-status--primary" %}
</td>
<td>{{ task_state.started_at }}</td>
<td>{{ task_state.finished_at }}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endif %}
{% endblock %}
{% block no_results_message %}
<p>{% trans "No pages/snippets have been submitted for moderation yet" %}</p>
{% endblock %}

Wyświetl plik

@ -792,7 +792,11 @@ class PageTypesUsageReportViewTest(WagtailTestUtils, TestCase):
def test_simple(self): def test_simple(self):
response = self.get() response = self.get()
self.assertEqual(response.status_code, 200) self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, "wagtailadmin/reports/page_types_usage.html") self.assertTemplateUsed(response, "wagtailadmin/reports/base_report.html")
self.assertTemplateUsed(
response,
"wagtailadmin/reports/page_types_usage_results.html",
)
def test_displays_only_page_types(self): def test_displays_only_page_types(self):
"""Asserts that the correct models are included in the queryset.""" """Asserts that the correct models are included in the queryset."""

Wyświetl plik

@ -104,7 +104,7 @@ class SiteHistoryReportFilterSet(WagtailFilterSet):
class LogEntriesView(ReportView): class LogEntriesView(ReportView):
template_name = "wagtailadmin/reports/site_history.html" results_template_name = "wagtailadmin/reports/site_history_results.html"
title = _("Site history") title = _("Site history")
header_icon = "history" header_icon = "history"
filterset_class = SiteHistoryReportFilterSet filterset_class = SiteHistoryReportFilterSet

Wyświetl plik

@ -6,6 +6,7 @@ from wagtail.admin.views.mixins import SpreadsheetExportMixin
class ReportView(SpreadsheetExportMixin, BaseListingView): class ReportView(SpreadsheetExportMixin, BaseListingView):
template_name = "wagtailadmin/reports/base_report.html" template_name = "wagtailadmin/reports/base_report.html"
results_template_name = "wagtailadmin/reports/base_report_results.html"
title = "" title = ""
paginate_by = 50 paginate_by = 50

Wyświetl plik

@ -96,7 +96,7 @@ class PageTypesUsageReportFilterSet(WagtailFilterSet):
class PageTypesUsageReportView(ReportView): class PageTypesUsageReportView(ReportView):
template_name = "wagtailadmin/reports/page_types_usage.html" results_template_name = "wagtailadmin/reports/page_types_usage_results.html"
title = _("Page types usage") title = _("Page types usage")
header_icon = "doc-empty-inverse" header_icon = "doc-empty-inverse"
filterset_class = PageTypesUsageReportFilterSet filterset_class = PageTypesUsageReportFilterSet

Wyświetl plik

@ -136,6 +136,7 @@ class WorkflowTasksReportFilterSet(WagtailFilterSet):
class WorkflowView(ReportView): class WorkflowView(ReportView):
template_name = "wagtailadmin/reports/workflow.html" template_name = "wagtailadmin/reports/workflow.html"
results_template_name = "wagtailadmin/reports/workflow_results.html"
title = _("Workflows") title = _("Workflows")
header_icon = "tasks" header_icon = "tasks"
filterset_class = WorkflowReportFilterSet filterset_class = WorkflowReportFilterSet
@ -208,6 +209,7 @@ class WorkflowView(ReportView):
class WorkflowTasksView(ReportView): class WorkflowTasksView(ReportView):
template_name = "wagtailadmin/reports/workflow_tasks.html" template_name = "wagtailadmin/reports/workflow_tasks.html"
results_template_name = "wagtailadmin/reports/workflow_tasks_results.html"
title = _("Workflow tasks") title = _("Workflow tasks")
header_icon = "thumbtack" header_icon = "thumbtack"
filterset_class = WorkflowTasksReportFilterSet filterset_class = WorkflowTasksReportFilterSet