Extract usage summary link into a shared include template

pull/10072/head
Sage Abdullah 2023-02-16 13:46:07 +00:00
rodzic fccf6f9070
commit b075205ea8
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: EB1A33CC51CC0217
3 zmienionych plików z 30 dodań i 32 usunięć

Wyświetl plik

@ -3,23 +3,7 @@
{% block main_content %}
{% if usage_url %}
<p>
<a href="{{ usage_url }}">
{% blocktrans trimmed with model_name=model_opts.verbose_name usage_url=usage_url count usage_count=usage_count asvar usage_message %}
This {{ model_name }} is currently used {{ usage_count }} time.
{% plural %}
This {{ model_name }} is currently used {{ usage_count }} times.
{% endblocktrans %}
{# Use capfirst in case the translated message starts with {{ model_name }}. #}
{{ usage_message|capfirst|safe }}
</a>
{% if is_protected %}
{% blocktrans trimmed with model_name=model_opts.verbose_name asvar protected_message %}
One or more usages of this {{ model_name }} prevent it from being deleted.
{% endblocktrans %}
{{ protected_message|capfirst }}
{% endif %}
</p>
{% include "wagtailadmin/shared/usage_summary.html" %}
{% endif %}
{% if not is_protected %}
<p>{{ view.confirmation_message }}</p>

Wyświetl plik

@ -7,21 +7,7 @@
{% include "wagtailadmin/shared/header.html" with title=del_str subtitle=page.get_admin_display_title icon="doc-empty-inverse" %}
<div class="nice-padding">
<p>
{% blocktrans trimmed with model_name=model_opts.verbose_name usage_url=usage_url count usage_count=usage_count asvar usage_message %}
This {{ model_name }} is currently <a href="{{ usage_url }}">used {{ usage_count }} time</a>.
{% plural %}
This {{ model_name }} is currently <a href="{{ usage_url }}">used {{ usage_count }} times</a>.
{% endblocktrans %}
{# Use capfirst in case the translated message starts with {{ model_name }}. #}
{{ usage_message|capfirst }}
{% if is_protected %}
{% blocktrans trimmed with model_name=model_opts.verbose_name asvar protected_message %}
One or more usages of this {{ model_name }} prevent it from being deleted.
{% endblocktrans %}
{{ protected_message|capfirst }}
{% endif %}
</p>
{% include "wagtailadmin/shared/usage_summary.html" %}
{% if not is_protected %}
<p>
{% trans 'Are you sure you want to delete this page?' %}

Wyświetl plik

@ -0,0 +1,28 @@
{% load i18n %}
{% comment "text/markdown" %}
This shared template is used to display the usage count for an object as a link
to the object's usage page. It is used by the admin's delete and unpublish views.
Variables this template accepts:
- `model_opts`: the model's options
- `usage_url`: the URL to the object's usage page
- `usage_count`: the number of times the object is used
- `is_protected` (optional): whether the object is protected from deletion
{% endcomment %}
<p>
<a href="{{ usage_url }}">
{% blocktrans trimmed with model_name=model_opts.verbose_name count usage_count=usage_count asvar usage_message %}
This {{ model_name }} is currently used {{ usage_count }} time.
{% plural %}
This {{ model_name }} is currently used {{ usage_count }} times.
{% endblocktrans %}
{# Use capfirst in case the translated message starts with {{ model_name }}. #}
{{ usage_message|capfirst }}
</a>
{% if is_protected %}
{% blocktrans trimmed with model_name=model_opts.verbose_name asvar protected_message %}
One or more usages of this {{ model_name }} prevent it from being deleted.
{% endblocktrans %}
{{ protected_message|capfirst }}
{% endif %}
</p>