Split out base report template into an empty base and a page-specific one

pull/5965/head
Karl Hobley 2020-03-19 10:55:51 +00:00 zatwierdzone przez Matt Westcott
rodzic a1b09f65c9
commit 1e4a331766
4 zmienionych plików z 49 dodań i 38 usunięć

Wyświetl plik

@ -46,7 +46,8 @@ This retrieves the queryset of pages for your report. For our example:
(string)
The template used to render your report. By default, this is ``"wagtailadmin/reports/base_report.html"``,
which has a listing based on the explorer views, displaying action buttons, as well as the title,
which provides an empty report page layout; an alternative base template ``"wagtailadmin/reports/base_page_report.html"``
is available, providing a listing based on the explorer views, displaying action buttons, as well as the title,
time of the last update, status, and specific type of any pages. In this example, we'll change this
to a new template in a later section.
@ -111,14 +112,14 @@ Customising templates
---------------------
For this example "pages with unpublished changes" report, we'll add an extra column to the listing template, showing the last
publication date for each page. To do this, we'll extend two templates: ``wagtailadmin/reports/base_report.html``, and
publication date for each page. To do this, we'll extend two templates: ``wagtailadmin/reports/base_page_report.html``, and
``wagtailadmin/reports/listing/_list_report.html``.
.. code-block:: html
# <project>/templates/reports/unpublished_changes_report.html
{# <project>/templates/reports/unpublished_changes_report.html #}
{% extends 'wagtailadmin/reports/base_report.html' %}
{% extends 'wagtailadmin/reports/base_page_report.html' %}
{% block listing %}
{% include 'reports/include/_list_unpublished_changes.html' %}
@ -131,7 +132,7 @@ publication date for each page. To do this, we'll extend two templates: ``wagtai
.. code-block:: html
# <project>/templates/reports/include/_list_unpublished_changes.html
{# <project>/templates/reports/include/_list_unpublished_changes.html #}
{% extends 'wagtailadmin/reports/listing/_list_report.html' %}
@ -139,7 +140,7 @@ publication date for each page. To do this, we'll extend two templates: ``wagtai
<th>Last Published</th>
{% endblock %}
{% block extra_page_data%}
{% block extra_page_data %}
<td valign="top">
{{ page.last_published_at }}
</td>
@ -225,9 +226,9 @@ The full code
.. code-block:: html
# <project>/templates/reports/unpublished_changes_report.html
{# <project>/templates/reports/unpublished_changes_report.html #}
{% extends 'wagtailadmin/reports/base_report.html' %}
{% extends 'wagtailadmin/reports/base_page_report.html' %}
{% block listing %}
{% include 'reports/include/_list_unpublished_changes.html' %}
@ -240,7 +241,7 @@ The full code
.. code-block:: html
# <project>/templates/reports/include/_list_unpublished_changes.html
{# <project>/templates/reports/include/_list_unpublished_changes.html #}
{% extends 'wagtailadmin/reports/listing/_list_report.html' %}
@ -248,7 +249,7 @@ The full code
<th>Last Published</th>
{% endblock %}
{% block extra_page_data%}
{% block extra_page_data %}
<td valign="top">
{{ page.last_published_at }}
</td>

Wyświetl plik

@ -0,0 +1,19 @@
{% extends 'wagtailadmin/reports/base_report.html' %}
{% load i18n wagtailadmin_tags %}
{% block results %}
{% with page_obj as pages %}
<div id="page-results">
{% if pages %}
{% block listing %}
{% include "wagtailadmin/reports/listing/_list_report.html" %}
{% endblock %}
{% paginate pages base_url=request.path %}
{% else %}
{% block no_results %}
<p>{% trans "No pages match this report's criteria." %}</p>
{% endblock %}
{% endif %}
</div>
{% endwith %}
{% endblock %}

Wyświetl plik

@ -1,5 +1,6 @@
{% extends "wagtailadmin/base.html" %}
{% load i18n wagtailadmin_tags %}
{% block titletag %}{{ title }}{% endblock %}
{% block content %}
@ -10,34 +11,24 @@
<h1 class="icon icon-{{ header_icon }}">{{ title }}{% if subtitle %} <span>{{ subtitle }}</span>{% endif %}</h1>
</div>
</div>
{% if view.list_export %}
<div class="right">
<div class="dropdown dropdown-button match-width">
<a href="?export=xlsx" class="button bicolor icon icon-download">{% trans 'Download XLSX' %}</a>
<div class="dropdown-toggle icon icon-arrow-down"></div>
<ul>
<li><a class="button bicolor icon icon-download" href="?export=csv">{% trans 'Download CSV' %}</a></li>
</ul>
</div>
</div>
{% endif %}
<div class="right">
{% block actions %}
{% if view.list_export %}
<div class="dropdown dropdown-button match-width">
<a href="?export=xlsx" class="button bicolor icon icon-download">{% trans 'Download XLSX' %}</a>
<div class="dropdown-toggle icon icon-arrow-down"></div>
<ul>
<li><a class="button bicolor icon icon-download" href="?export=csv">{% trans 'Download CSV' %}</a></li>
</ul>
</div>
{% endif %}
{% endblock %}
</div>
</div>
</header>
{% with page_obj as pages %}
<div id="page-results">
<div class="nice-padding">
{% if pages %}
{% block listing %}
{% include "wagtailadmin/reports/listing/_list_report.html" %}
{% endblock %}
{% paginate pages base_url=request.path %}
{% else %}
{% block no_results %}
<p>{% trans "No pages match this report's criteria." %}</p>
{% endblock %}
{% endif %}
</div>
</div>
{% endwith %}
<div class="nice-padding">
{% block results %}
{% endblock %}
</div>
{% endblock %}

Wyświetl plik

@ -1,4 +1,4 @@
{% extends 'wagtailadmin/reports/base_report.html' %}
{% extends 'wagtailadmin/reports/base_page_report.html' %}
{% load i18n %}
{% block listing %}
{% include "wagtailadmin/reports/listing/_list_unlock.html" %}