kopia lustrzana https://github.com/wagtail/wagtail
Use get_admin_display_title in admin
rodzic
9710c292eb
commit
8a3c47f76a
|
@ -6,6 +6,7 @@ Changelog
|
|||
|
||||
* Added support of a custom `edit_handler` in site settings (Axel Haustant)
|
||||
* Added `get_landing_page_template` getter method to `AbstractForm` (Gagaro)
|
||||
* Added `Page.get_admin_display_title` method to override how the title is displayed in the admin (Henk-Jan van Hasselaar)
|
||||
* Fix: `AbstractForm` now respects custom `get_template` methods on the page model (Gagaro)
|
||||
|
||||
|
||||
|
|
|
@ -172,6 +172,7 @@ Contributors
|
|||
* Mattias Loverot
|
||||
* Ricky Robinett
|
||||
* Axel Haustant
|
||||
* Henk-Jan van Hasselaar
|
||||
|
||||
Translators
|
||||
===========
|
||||
|
|
|
@ -111,6 +111,8 @@ In addition to the model fields provided, ``Page`` has many properties and metho
|
|||
|
||||
.. automethod:: get_template
|
||||
|
||||
.. automethod:: get_admin_display_title
|
||||
|
||||
.. autoattribute:: preview_modes
|
||||
|
||||
.. automethod:: serve_preview
|
||||
|
|
|
@ -16,6 +16,7 @@ Minor features
|
|||
|
||||
* Added support of a custom ``edit_handler`` for site settings. See :ref:`docs for the site settings module <edit_handlers_settings>`. (Axel Haustant)
|
||||
* Added ``get_landing_page_template`` getter method to ``AbstractForm`` (Gagaro)
|
||||
* Added ``Page.get_admin_display_title`` method to override how the title is displayed in the admin (Henk-Jan van Hasselaar)
|
||||
|
||||
|
||||
Bug fixes
|
||||
|
|
|
@ -11,7 +11,7 @@ class PageChoiceField(forms.ModelChoiceField):
|
|||
def label_from_instance(self, obj):
|
||||
bits = []
|
||||
for ancestor in obj.get_ancestors(inclusive=True).exclude(depth=1):
|
||||
bits.append(ancestor.title)
|
||||
bits.append(ancestor.get_admin_display_title())
|
||||
return mark_safe('<span class="icon icon-arrow-right"></span>'.join(bits))
|
||||
|
||||
|
||||
|
|
|
@ -72,7 +72,7 @@ def get_navigation_menu_items(user):
|
|||
)
|
||||
)
|
||||
|
||||
pages = Page.objects.filter(criteria).order_by('path')
|
||||
pages = Page.objects.filter(criteria).order_by('path').specific()
|
||||
|
||||
# Turn this into a tree structure:
|
||||
# tree_node = (page, children)
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
<tr>
|
||||
<td class="title" valign="top">
|
||||
<h2>
|
||||
<a href="{% url 'wagtailadmin_pages:edit' revision.page.id %}" title="{% trans 'Edit this page' %}">{{ revision.page.title }}</a>
|
||||
<a href="{% url 'wagtailadmin_pages:edit' revision.page.id %}" title="{% trans 'Edit this page' %}">{{ revision.page.get_admin_display_title }}</a>
|
||||
|
||||
{% include "wagtailadmin/pages/listing/_privacy_indicator.html" with page=revision.page %}
|
||||
{% include "wagtailadmin/pages/listing/_locked_indicator.html" with page=revision.page %}
|
||||
|
@ -44,7 +44,7 @@
|
|||
</ul>
|
||||
</td>
|
||||
<td valign="top">
|
||||
<a href="{% url 'wagtailadmin_explore' revision.page.get_parent.id %}">{{ revision.page.get_parent.title }}</a>
|
||||
<a href="{% url 'wagtailadmin_explore' revision.page.get_parent.id %}">{{ revision.page.get_parent.get_admin_display_title }}</a>
|
||||
</td>
|
||||
<td class="type" valign="top">
|
||||
{{ revision.page.content_type.model_class.get_verbose_name }}
|
||||
|
@ -52,7 +52,7 @@
|
|||
<td valign="top">
|
||||
<div class="human-readable-date" title="{{ revision.created_at|date:"d M Y H:i" }}">{{ revision.created_at|timesince }} ago </div>
|
||||
by {{ revision.user.get_full_name|default:revision.user.get_username }}
|
||||
</td>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
|
|
|
@ -15,28 +15,28 @@
|
|||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for revision in last_edits %}
|
||||
{% for revision, page in last_edits %}
|
||||
<tr>
|
||||
<td class="title" valign="top">
|
||||
<h2>
|
||||
<a href="{% url 'wagtailadmin_pages:edit' revision.page.id %}" title="{% trans 'Edit this page' %}">{{ revision.page.title }}</a>
|
||||
<a href="{% url 'wagtailadmin_pages:edit' page.id %}" title="{% trans 'Edit this page' %}">{{ page.get_admin_display_title }}</a>
|
||||
|
||||
{% include "wagtailadmin/pages/listing/_privacy_indicator.html" with page=revision.page %}
|
||||
{% include "wagtailadmin/pages/listing/_locked_indicator.html" with page=revision.page %}
|
||||
{% include "wagtailadmin/pages/listing/_privacy_indicator.html" with page=page %}
|
||||
{% include "wagtailadmin/pages/listing/_locked_indicator.html" with page=page %}
|
||||
</h2>
|
||||
<ul class="actions">
|
||||
<li><a href="{% url 'wagtailadmin_pages:edit' revision.page.id %}" class="button button-small button-secondary">{% trans "Edit" %}</a></li>
|
||||
{% if revision.page.has_unpublished_changes %}
|
||||
<li><a href="{% url 'wagtailadmin_pages:view_draft' revision.page.id %}" class="button button-small button-secondary">{% trans 'Draft' %}</a></li>
|
||||
<li><a href="{% url 'wagtailadmin_pages:edit' page.id %}" class="button button-small button-secondary">{% trans "Edit" %}</a></li>
|
||||
{% if page.has_unpublished_changes %}
|
||||
<li><a href="{% url 'wagtailadmin_pages:view_draft' page.id %}" class="button button-small button-secondary">{% trans 'Draft' %}</a></li>
|
||||
{% endif %}
|
||||
{% if revision.page.live %}
|
||||
<li><a href="{{ revision.page.url }}" class="button button-small button-secondary">{% trans 'Live' %}</a></li>
|
||||
{% if page.live %}
|
||||
<li><a href="{{ page.url }}" class="button button-small button-secondary">{% trans 'Live' %}</a></li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
</td>
|
||||
<td valign="top"><div class="human-readable-date" title="{{ revision.created_at|date:"d M Y H:i" }}">{{ revision.created_at|timesince }} ago</div></td>
|
||||
<td valign="top">
|
||||
{% include "wagtailadmin/shared/page_status_tag.html" with page=revision.page %}
|
||||
{% include "wagtailadmin/shared/page_status_tag.html" with page=page %}
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
|
@ -44,4 +44,4 @@
|
|||
</table>
|
||||
</section>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
|
|
@ -2,6 +2,6 @@
|
|||
{% load i18n %}
|
||||
|
||||
{% block content %}
|
||||
<p>{% blocktrans with title=revision.page.title|safe %}The page "{{ title }}" has been approved.{% endblocktrans %}</p>
|
||||
<p>{% blocktrans with title=revision.page.get_admin_display_title|safe %}The page "{{ title }}" has been approved.{% endblocktrans %}</p>
|
||||
<p>{% trans "You can view the page here:" %} <a href="{{ revision.page.full_url }}">{{ revision.page.full_url }}</a></p>
|
||||
{% endblock %}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
{% load i18n %}
|
||||
|
||||
{% block content %}
|
||||
{% blocktrans with title=revision.page.title|safe %}The page "{{ title }}" has been approved.{% endblocktrans %}
|
||||
{% blocktrans with title=revision.page.get_admin_display_title|safe %}The page "{{ title }}" has been approved.{% endblocktrans %}
|
||||
|
||||
{% trans "You can view the page here:" %} {{ revision.page.full_url }}
|
||||
{% endblock %}
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
{% load i18n %}
|
||||
|
||||
{% blocktrans with title=revision.page.title|safe %}The page "{{ title }}" has been approved{% endblocktrans %}
|
||||
{% blocktrans with title=revision.page.get_admin_display_title|safe %}The page "{{ title }}" has been approved{% endblocktrans %}
|
||||
|
|
|
@ -2,6 +2,6 @@
|
|||
{% load i18n %}
|
||||
|
||||
{% block content %}
|
||||
<p>{% blocktrans with title=revision.page.title|safe %}The page "{{ title }}" has been rejected.{% endblocktrans %}</p>
|
||||
<p>{% blocktrans with title=revision.page.get_admin_display_title|safe %}The page "{{ title }}" has been rejected.{% endblocktrans %}</p>
|
||||
<p>{% trans "You can edit the page here:"%} <a href="{{ settings.BASE_URL }}{% url 'wagtailadmin_pages:edit' revision.page.id %}">{{ settings.BASE_URL }}{% url 'wagtailadmin_pages:edit' revision.page.id %}</a></p>
|
||||
{% endblock %}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
{% load i18n %}
|
||||
|
||||
{% block content %}
|
||||
{% blocktrans with title=revision.page.title|safe %}The page "{{ title }}" has been rejected.{% endblocktrans %}
|
||||
{% blocktrans with title=revision.page.get_admin_display_title|safe %}The page "{{ title }}" has been rejected.{% endblocktrans %}
|
||||
|
||||
{% trans "You can edit the page here:"%} {{ settings.BASE_URL }}{% url 'wagtailadmin_pages:edit' revision.page.id %}
|
||||
{% endblock %}
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
{% load i18n %}
|
||||
|
||||
{% blocktrans with title=revision.page.title|safe %}The page "{{ title }}" has been rejected{% endblocktrans %}
|
||||
{% blocktrans with title=revision.page.get_admin_display_title|safe %}The page "{{ title }}" has been rejected{% endblocktrans %}
|
||||
|
|
|
@ -4,5 +4,5 @@
|
|||
|
||||
<div class="nice-padding">
|
||||
<p>{% trans "This page has been made private by a parent page." %}</p>
|
||||
<p>{% trans "You can edit the privacy settings on:" %} <a href="{% url 'wagtailadmin_pages:edit' page_with_restriction.id %}">{{ page_with_restriction.title }}</a>
|
||||
<p>{% trans "You can edit the privacy settings on:" %} <a href="{% url 'wagtailadmin_pages:edit' page_with_restriction.id %}">{{ page_with_restriction.get_admin_display_title }}</a>
|
||||
</div>
|
||||
|
|
|
@ -2,11 +2,11 @@
|
|||
{% load i18n %}
|
||||
{% load wagtailadmin_tags %}
|
||||
|
||||
{% block titletag %}{% blocktrans with title=parent_page.title %}Create a page in {{ title }}{% endblocktrans %}{% endblock %}
|
||||
{% block titletag %}{% blocktrans with title=parent_page.get_admin_display_title %}Create a page in {{ title }}{% endblocktrans %}{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
{% trans "Create a page in" as create_str %}
|
||||
{% include "wagtailadmin/shared/header.html" with title=create_str subtitle=parent_page.title icon="doc-empty-inverse" %}
|
||||
{% include "wagtailadmin/shared/header.html" with title=create_str subtitle=parent_page.get_admin_display_title icon="doc-empty-inverse" %}
|
||||
|
||||
<div class="nice-padding">
|
||||
<p>{% trans "Choose which type of page you'd like to create." %}</p>
|
||||
|
@ -23,7 +23,7 @@
|
|||
<small class="col6" style="text-align:right">
|
||||
<a href="{% url 'wagtailadmin_pages:type_use' app_label model_name %}" class="nolink">{% blocktrans with page_type=verbose_name %}Pages using {{ page_type }}{% endblocktrans %}</a>
|
||||
</small>
|
||||
|
||||
|
||||
</div>
|
||||
</li>
|
||||
{% endfor %}
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
{% extends "wagtailadmin/base.html" %}
|
||||
{% load i18n wagtailadmin_tags %}
|
||||
{% block titletag %}{% blocktrans with title=page.title %}Delete {{ title }}{% endblocktrans %}{% endblock %}
|
||||
{% block titletag %}{% blocktrans with title=page.get_admin_display_title %}Delete {{ title }}{% endblocktrans %}{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
{% trans "Delete" as del_str %}
|
||||
{% include "wagtailadmin/shared/header.html" with title=del_str subtitle=page.title icon="doc-empty-inverse" %}
|
||||
{% include "wagtailadmin/shared/header.html" with title=del_str subtitle=page.get_admin_display_title icon="doc-empty-inverse" %}
|
||||
|
||||
<div class="nice-padding">
|
||||
<p>
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
{% extends "wagtailadmin/base.html" %}
|
||||
{% load i18n %}
|
||||
{% block titletag %}{% blocktrans with title=page.title %}Move {{ title }}{% endblocktrans %}{% endblock %}
|
||||
{% block titletag %}{% blocktrans with title=page.get_admin_display_title %}Move {{ title }}{% endblocktrans %}{% endblock %}
|
||||
{% block content %}
|
||||
{% trans "Move" as move_str %}
|
||||
{% include "wagtailadmin/shared/header.html" with title=move_str subtitle=page_to_move.title icon="doc-empty-inverse" %}
|
||||
{% include "wagtailadmin/shared/header.html" with title=move_str subtitle=page_to_move.get_admin_display_title icon="doc-empty-inverse" %}
|
||||
|
||||
<div class="nice-padding">
|
||||
{% if page_to_move.is_leaf %}
|
||||
<p>{% blocktrans with title=destination.title %}Are you sure you want to move this page into '{{ title }}'?{% endblocktrans %}</p>
|
||||
<p>{% blocktrans with title=destination.get_admin_display_title %}Are you sure you want to move this page into '{{ title }}'?{% endblocktrans %}</p>
|
||||
{% else %}
|
||||
<p>{% blocktrans with title=destination.title %}Are you sure you want to move this page and all of its children into '{{ title }}'?{% endblocktrans %}</p>
|
||||
<p>{% blocktrans with title=destination.get_admin_display_title %}Are you sure you want to move this page and all of its children into '{{ title }}'?{% endblocktrans %}</p>
|
||||
{% endif %}
|
||||
|
||||
<form action="{% url 'wagtailadmin_pages:move_confirm' page_to_move.id destination.id %}" method="POST">
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
{% extends "wagtailadmin/base.html" %}
|
||||
{% load i18n %}
|
||||
{% block titletag %}{% blocktrans with title=page.title%}Unpublish {{ title }}{% endblocktrans %}{% endblock %}
|
||||
{% block titletag %}{% blocktrans with title=page.get_admin_display_title %}Unpublish {{ title }}{% endblocktrans %}{% endblock %}
|
||||
{% block content %}
|
||||
{% trans "Unpublish" as unpublish_str %}
|
||||
{% include "wagtailadmin/shared/header.html" with title=unpublish_str subtitle=page.title icon="doc-empty-inverse" %}
|
||||
{% include "wagtailadmin/shared/header.html" with title=unpublish_str subtitle=page.get_admin_display_title icon="doc-empty-inverse" %}
|
||||
|
||||
<div class="nice-padding">
|
||||
<p>{% trans "Are you sure you want to unpublish this page?" %}</p>
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
{% extends "wagtailadmin/base.html" %}
|
||||
{% load i18n %}
|
||||
{% block titletag %}{% blocktrans with title=page.title %}Copy {{ title }}{% endblocktrans %}{% endblock %}
|
||||
{% block titletag %}{% blocktrans with title=page.get_admin_display_title %}Copy {{ title }}{% endblocktrans %}{% endblock %}
|
||||
{% block content %}
|
||||
{% trans "Copy" as copy_str %}
|
||||
{% include "wagtailadmin/shared/header.html" with title=copy_str subtitle=page.title icon="doc-empty-inverse" %}
|
||||
{% include "wagtailadmin/shared/header.html" with title=copy_str subtitle=page.get_admin_display_title icon="doc-empty-inverse" %}
|
||||
|
||||
<div class="nice-padding">
|
||||
<form action="{% url 'wagtailadmin_pages:copy' page.id %}" method="POST" novalidate>
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
{% load wagtailadmin_tags %}
|
||||
{% load gravatar %}
|
||||
{% load i18n %}
|
||||
{% block titletag %}{% blocktrans with title=page.title page_type=content_type.model_class.get_verbose_name %}Editing {{ page_type }}: {{ title }}{% endblocktrans %}{% endblock %}
|
||||
{% block titletag %}{% blocktrans with title=page.get_admin_display_title page_type=content_type.model_class.get_verbose_name %}Editing {{ page_type }}: {{ title }}{% endblocktrans %}{% endblock %}
|
||||
{% block bodyclass %}page-editor {% if page.live %}page-is-live{% endif %} model-{{ content_type.model }}{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
|
@ -12,7 +12,7 @@
|
|||
|
||||
<div class="row row-flush">
|
||||
<div class="left col9">
|
||||
<h1 class="icon icon-doc-empty-inverse">{% blocktrans with title=page.title page_type=content_type.model_class.get_verbose_name %}Editing {{ page_type }} <span>{{ title }}</span>{% endblocktrans %}</h1>
|
||||
<h1 class="icon icon-doc-empty-inverse">{% blocktrans with title=page.get_admin_display_title page_type=content_type.model_class.get_verbose_name %}Editing {{ page_type }} <span>{{ title }}</span>{% endblocktrans %}</h1>
|
||||
</div>
|
||||
<div class="right col3">
|
||||
{% trans "Status" %}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{% extends "wagtailadmin/base.html" %}
|
||||
{% load wagtailadmin_tags staticfiles i18n %}
|
||||
{% block titletag %}{% blocktrans with title=parent_page.title %}Exploring {{ title }}{% endblocktrans %}{% endblock %}
|
||||
{% block titletag %}{% blocktrans with title=parent_page.get_admin_display_title %}Exploring {{ title }}{% endblocktrans %}{% endblock %}
|
||||
{% block bodyclass %}page-explorer {% if ordering == 'ord' %}reordering{% endif %}{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
|
|
|
@ -45,7 +45,7 @@
|
|||
{% if pages %}
|
||||
{% for page in pages %}
|
||||
{% page_permissions page as page_perms %}
|
||||
<tr {% if ordering == "ord" %}id="page_{{ page.id }}" data-page-title="{{ page.title }}"{% endif %} class="{% if not page.live %}unpublished{% endif %} {% block page_row_classname %}{% endblock %}">
|
||||
<tr {% if ordering == "ord" %}id="page_{{ page.id }}" data-page-title="{{ page.get_admin_display_title }}"{% endif %} class="{% if not page.live %}unpublished{% endif %} {% block page_row_classname %}{% endblock %}">
|
||||
{% if show_ordering_column %}
|
||||
<td class="ord">{% if orderable and ordering == "ord" %}<div class="handle icon icon-grip text-replace">{% trans 'Drag' %}</div>{% endif %}</td>
|
||||
{% endif %}
|
||||
|
@ -57,7 +57,7 @@
|
|||
{% with page.get_parent as parent %}
|
||||
<td class="parent" valign="top">
|
||||
{% if parent %}
|
||||
<a href="{% url 'wagtailadmin_explore' parent.id %}">{{ parent.title }}</a>
|
||||
<a href="{% url 'wagtailadmin_explore' parent.id %}">{{ parent.get_admin_display_title }}</a>
|
||||
{% endif %}
|
||||
</td>
|
||||
{% endwith %}
|
||||
|
|
|
@ -6,6 +6,6 @@ Navigation controls for the page listing in 'choose' mode
|
|||
|
||||
<td class="{% if allow_navigation and page.can_descend %}children{% endif %}">
|
||||
{% if allow_navigation and page.can_descend %}
|
||||
<a href="{% url 'wagtailadmin_choose_page_child' page.id %}{% querystring p=None %}" class="icon text-replace icon-arrow-right navigate-pages" title="{% blocktrans with title=page.title %}Explore subpages of '{{ title }}'{% endblocktrans %}">{% trans 'Explore' %}</a>
|
||||
<a href="{% url 'wagtailadmin_choose_page_child' page.id %}{% querystring p=None %}" class="icon text-replace icon-arrow-right navigate-pages" title="{% blocktrans with title=page.get_admin_display_title %}Explore subpages of '{{ title }}'{% endblocktrans %}">{% trans 'Explore' %}</a>
|
||||
{% endif %}
|
||||
</td>
|
||||
|
|
|
@ -7,9 +7,9 @@ Navigation controls for the page listing in 'explore' mode
|
|||
<td class="{% if allow_navigation %}{% if page.is_navigable %}children{% else %}no-children{% endif %}{% endif %}">
|
||||
{% if allow_navigation %}
|
||||
{% if page.is_navigable %}
|
||||
<a href="{% url 'wagtailadmin_explore' page.id %}" class="icon text-replace icon-arrow-right" title="{% blocktrans with title=page.title %}Explore child pages of '{{ title }}'{% endblocktrans %}">{% trans "Explore" %}</a>
|
||||
<a href="{% url 'wagtailadmin_explore' page.id %}" class="icon text-replace icon-arrow-right" title="{% blocktrans with title=page.get_admin_display_title %}Explore child pages of '{{ title }}'{% endblocktrans %}">{% trans "Explore" %}</a>
|
||||
{% elif page_perms.can_add_subpage %}
|
||||
<a href="{% url 'wagtailadmin_pages:add_subpage' page.id %}" class="icon text-replace icon-plus-inverse" title="{% blocktrans with title=page.title %}Add a child page to '{{ title }}'{% endblocktrans %}">{% trans 'Add subpage' %}</a>
|
||||
<a href="{% url 'wagtailadmin_pages:add_subpage' page.id %}" class="icon text-replace icon-plus-inverse" title="{% blocktrans with title=page.get_admin_display_title %}Add a child page to '{{ title }}'{% endblocktrans %}">{% trans 'Add subpage' %}</a>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</td>
|
||||
|
|
|
@ -6,6 +6,6 @@ Navigation controls for the page listing in 'move' mode
|
|||
|
||||
<td class="{% if page.can_descend %}children{% endif %}">
|
||||
{% if page.can_descend %}
|
||||
<a href="{% url 'wagtailadmin_pages:move_choose_destination' page_to_move.id page.id %}" class="icon text-replace icon-arrow-right navigate-pages" title="{% blocktrans with title=page.title %}Explore subpages of '{{ title }}'{% endblocktrans %}">{% trans 'Explore' %}</a>
|
||||
<a href="{% url 'wagtailadmin_pages:move_choose_destination' page_to_move.id page.id %}" class="icon text-replace icon-arrow-right navigate-pages" title="{% blocktrans with title=page.get_admin_display_title %}Explore subpages of '{{ title }}'{% endblocktrans %}">{% trans 'Explore' %}</a>
|
||||
{% endif %}
|
||||
</td>
|
||||
|
|
|
@ -6,9 +6,9 @@ Expects a variable 'page', the page instance.
|
|||
|
||||
<h2>
|
||||
{% if page.can_choose %}
|
||||
<a class="choose-page" href="#{{ page.id }}" data-id="{{ page.id }}" data-title="{{ page.title }}" data-url="{{ page.url }}" data-parent-id="{{ page.get_parent.id }}" data-edit-url="{% url 'wagtailadmin_pages:edit' page.id %}">{{ page.title }}</a>
|
||||
<a class="choose-page" href="#{{ page.id }}" data-id="{{ page.id }}" data-title="{{ page.get_admin_display_title }}" data-url="{{ page.url }}" data-parent-id="{{ page.get_parent.id }}" data-edit-url="{% url 'wagtailadmin_pages:edit' page.id %}">{{ page.get_admin_display_title }}</a>
|
||||
{% else %}
|
||||
{{ page.title }}
|
||||
{{ page.get_admin_display_title }}
|
||||
{% endif %}
|
||||
|
||||
{% include "wagtailadmin/pages/listing/_privacy_indicator.html" with page=page %}
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
|
||||
<h2>
|
||||
{% if page_perms.can_edit %}
|
||||
<a href="{% url 'wagtailadmin_pages:edit' page.id %}" title="{% trans 'Edit this page' %}">{{ page.title }}</a>
|
||||
<a href="{% url 'wagtailadmin_pages:edit' page.id %}" title="{% trans 'Edit this page' %}">{{ page.get_admin_display_title }}</a>
|
||||
{% else %}
|
||||
{{ page.title }}
|
||||
{{ page.get_admin_display_title }}
|
||||
{% endif %}
|
||||
|
||||
{% include "wagtailadmin/pages/listing/_privacy_indicator.html" with page=page %}
|
||||
|
|
|
@ -6,9 +6,9 @@ Expects a variable 'page', the page instance.
|
|||
|
||||
<h2>
|
||||
{% if page.can_choose %}
|
||||
<a href="{% url 'wagtailadmin_pages:move_confirm' page_to_move.id page.id %}">{{ page.title }}</a>
|
||||
<a href="{% url 'wagtailadmin_pages:move_confirm' page_to_move.id page.id %}">{{ page.specific.get_admin_display_title }}</a>
|
||||
{% else %}
|
||||
{{ page.title }}
|
||||
{{ page.get_admin_display_title }}
|
||||
{% endif %}
|
||||
|
||||
{% include "wagtailadmin/pages/listing/_privacy_indicator.html" with page=page %}
|
||||
|
|
|
@ -5,9 +5,9 @@
|
|||
|
||||
<h2>
|
||||
{% if parent_page_perms.can_edit %}
|
||||
<a href="{% url 'wagtailadmin_pages:edit' parent_page.id %}">{{ parent_page.title }}</a>
|
||||
<a href="{% url 'wagtailadmin_pages:edit' parent_page.id %}">{{ parent_page.get_admin_display_title }}</a>
|
||||
{% else %}
|
||||
{{ parent_page.title }}
|
||||
{{ parent_page.get_admin_display_title }}
|
||||
{% endif %}
|
||||
|
||||
{% include "wagtailadmin/pages/listing/_locked_indicator.html" with page=parent_page %}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
{% extends "wagtailadmin/base.html" %}
|
||||
{% load i18n wagtailadmin_tags %}
|
||||
{% block titletag %}{% blocktrans with title=page_to_move.title %}Select a new parent page for {{ title }}{% endblocktrans %}{% endblock %}
|
||||
{% block titletag %}{% blocktrans with title=page_to_move.get_admin_display_title %}Select a new parent page for {{ title }}{% endblocktrans %}{% endblock %}
|
||||
{% block content %}
|
||||
<header class="nice-padding">
|
||||
<h1 class="icon icon-doc-empty-inverse">{% blocktrans with title=page_to_move.title %}Select a new parent page for <span>{{ title }}</span>{% endblocktrans %}</h1>
|
||||
<h1 class="icon icon-doc-empty-inverse">{% blocktrans with title=page_to_move.get_admin_display_title %}Select a new parent page for <span>{{ title }}</span>{% endblocktrans %}</h1>
|
||||
</header>
|
||||
|
||||
<div class="nice-padding">
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
{% extends "wagtailadmin/base.html" %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block titletag %}{% blocktrans with title=page.title %}Revisions of {{ title }}{% endblocktrans %}{% endblock %}
|
||||
{% block titletag %}{% blocktrans with title=page.get_admin_display_title %}Revisions of {{ title }}{% endblocktrans %}{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
{% trans "Revisions of" as revisions_str %}
|
||||
{% include "wagtailadmin/shared/header.html" with title=revisions_str subtitle=page.title icon="doc-empty-inverse" %}
|
||||
{% include "wagtailadmin/shared/header.html" with title=revisions_str subtitle=page.get_admin_display_title icon="doc-empty-inverse" %}
|
||||
|
||||
<div class="nice-padding">
|
||||
<div id="revision-results" class="revisions">
|
||||
|
|
|
@ -5,10 +5,10 @@
|
|||
{% if page.is_root %}
|
||||
<li class="home"><a href="{% if choosing %}{% url 'wagtailadmin_choose_page_child' page.id %}{% querystring p=None %}{% else %}{% url 'wagtailadmin_explore_root' %}{% endif %}" class="{% if choosing %}navigate-pages{% endif %} icon icon-home text-replace">{% trans 'Home' %}</a></li>
|
||||
{% else %}
|
||||
<li><a href="{% if choosing %}{% url 'wagtailadmin_choose_page_child' page.id %}{% querystring p=None %}{% else %}{% url 'wagtailadmin_explore' page.id %}{% endif %}" {% if choosing %}class="navigate-pages"{% endif %}>{{ page.title }}</a></li>
|
||||
<li><a href="{% if choosing %}{% url 'wagtailadmin_choose_page_child' page.id %}{% querystring p=None %}{% else %}{% url 'wagtailadmin_explore' page.id %}{% endif %}" {% if choosing %}class="navigate-pages"{% endif %}>{{ page.get_admin_display_title }}</a></li>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% if include_self %}
|
||||
<li><a href="{% if choosing %}{% url 'wagtailadmin_choose_page_child' page.id %}{% querystring p=None %}{% else %}{% url 'wagtailadmin_explore' page.id %}{% endif %}" {% if choosing %}class="navigate-pages"{% endif %}>{{ page.title }}</a></li>
|
||||
<li><a href="{% if choosing %}{% url 'wagtailadmin_choose_page_child' page.id %}{% querystring p=None %}{% else %}{% url 'wagtailadmin_explore' page.id %}{% endif %}" {% if choosing %}class="navigate-pages"{% endif %}>{{ page.get_admin_display_title }}</a></li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
{% for page, children in nodes %}
|
||||
<li {% if children %}class="has-children"{% endif %}>
|
||||
<a href="{% url 'wagtailadmin_explore' page.id %}" class="icon icon-folder-open-inverse">{{ page.title }}</a>
|
||||
<a href="{% url 'wagtailadmin_explore' page.id %}" class="icon icon-folder-open-inverse">{{ page.get_admin_display_title }}</a>
|
||||
{% if children %}
|
||||
<div class="children icon icon-arrow-right"></div>
|
||||
<ul class="dl-submenu">
|
||||
|
@ -10,4 +10,4 @@
|
|||
</ul>
|
||||
{% endif %}
|
||||
</li>
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{% extends "wagtailadmin/widgets/chooser.html" %}
|
||||
|
||||
{% block chosen_state_view %}
|
||||
<span class="title">{{ page.title }}</span>
|
||||
<span class="title">{{ page.get_admin_display_title }}</span>
|
||||
{% endblock %}
|
||||
|
||||
{% block edit_chosen_item_url %}{% if page %}{% url 'wagtailadmin_pages:edit' page.id %}{% endif %}{% endblock %}
|
||||
|
|
|
@ -52,13 +52,13 @@ class TestExplorerNavView(TestCase, WagtailTestUtils):
|
|||
self.assertEqual(response.status_code, 200)
|
||||
self.assertTemplateUsed('wagtailadmin/shared/explorer_nav.html')
|
||||
self.assertEqual(len(response.context['nodes']), 3)
|
||||
self.assertEqual(response.context['nodes'][0][0], Page.objects.get(id=2))
|
||||
self.assertEqual(response.context['nodes'][1][0], Page.objects.get(id=4))
|
||||
self.assertEqual(response.context['nodes'][1][1][0][0], Page.objects.get(id=5))
|
||||
self.assertEqual(response.context['nodes'][1][1][0][1][0][0], Page.objects.get(id=7))
|
||||
self.assertEqual(response.context['nodes'][0][0], Page.objects.get(id=2).specific)
|
||||
self.assertEqual(response.context['nodes'][1][0], Page.objects.get(id=4).specific)
|
||||
self.assertEqual(response.context['nodes'][1][1][0][0], Page.objects.get(id=5).specific)
|
||||
self.assertEqual(response.context['nodes'][1][1][0][1][0][0], Page.objects.get(id=7).specific)
|
||||
# Even though example.com's Home 2 has no children, it's still displayed because it's at
|
||||
# the top menu level for this user
|
||||
self.assertEqual(response.context['nodes'][2][0], Page.objects.get(id=10))
|
||||
self.assertEqual(response.context['nodes'][2][0], Page.objects.get(id=10).specific)
|
||||
|
||||
def test_nav_root_for_nonadmin_is_closest_common_ancestor(self):
|
||||
self.assertTrue(self.client.login(username='jane', password='password'))
|
||||
|
@ -67,7 +67,7 @@ class TestExplorerNavView(TestCase, WagtailTestUtils):
|
|||
self.assertEqual(response.status_code, 200)
|
||||
self.assertTemplateUsed('wagtailadmin/shared/explorer_nav.html')
|
||||
self.assertEqual(len(response.context['nodes']), 1)
|
||||
self.assertEqual(response.context['nodes'][0][0], Page.objects.get(id=2))
|
||||
self.assertEqual(response.context['nodes'][0][0], Page.objects.get(id=2).specific)
|
||||
self.client.logout()
|
||||
|
||||
self.assertTrue(self.client.login(username='sam', password='password'))
|
||||
|
@ -76,8 +76,8 @@ class TestExplorerNavView(TestCase, WagtailTestUtils):
|
|||
self.assertEqual(response.status_code, 200)
|
||||
self.assertTemplateUsed('wagtailadmin/shared/explorer_nav.html')
|
||||
self.assertEqual(len(response.context['nodes']), 2)
|
||||
self.assertEqual(response.context['nodes'][0][0], Page.objects.get(id=2))
|
||||
self.assertEqual(response.context['nodes'][1][0], Page.objects.get(id=4))
|
||||
self.assertEqual(response.context['nodes'][0][0], Page.objects.get(id=2).specific)
|
||||
self.assertEqual(response.context['nodes'][1][0], Page.objects.get(id=4).specific)
|
||||
|
||||
def test_nonadmin_sees_leaf_pages_at_root_level(self):
|
||||
self.assertTrue(self.client.login(username='bob', password='password'))
|
||||
|
@ -89,7 +89,7 @@ class TestExplorerNavView(TestCase, WagtailTestUtils):
|
|||
self.assertEqual(response.status_code, 200)
|
||||
self.assertTemplateUsed('wagtailadmin/shared/explorer_nav.html')
|
||||
self.assertEqual(len(response.context['nodes']), 1)
|
||||
self.assertEqual(response.context['nodes'][0][0], Page.objects.get(id=6))
|
||||
self.assertEqual(response.context['nodes'][0][0], Page.objects.get(id=6).specific)
|
||||
self.assertEqual(len(response.context['nodes'][0][1]), 0)
|
||||
|
||||
def test_nonadmin_sees_pages_below_closest_common_ancestor(self):
|
||||
|
@ -104,13 +104,13 @@ class TestExplorerNavView(TestCase, WagtailTestUtils):
|
|||
self.assertTemplateUsed('wagtailadmin/shared/explorer_nav.html')
|
||||
|
||||
self.assertEqual(len(response.context['nodes']), 2)
|
||||
self.assertEqual(response.context['nodes'][0][0], Page.objects.get(id=5))
|
||||
self.assertEqual(response.context['nodes'][0][0], Page.objects.get(id=5).specific)
|
||||
# page-1 is childless, but user has direct permission on it, so it should be shown
|
||||
self.assertEqual(len(response.context['nodes'][0][1]), 1)
|
||||
self.assertEqual(response.context['nodes'][0][1][0][0], Page.objects.get(id=6))
|
||||
self.assertEqual(response.context['nodes'][0][1][0][0], Page.objects.get(id=6).specific)
|
||||
self.assertEqual(len(response.context['nodes'][0][1][0][1]), 0)
|
||||
|
||||
self.assertEqual(response.context['nodes'][1][0], Page.objects.get(id=8))
|
||||
self.assertEqual(response.context['nodes'][1][0], Page.objects.get(id=8).specific)
|
||||
self.assertEqual(len(response.context['nodes'][1][1]), 0)
|
||||
|
||||
def test_nonadmin_sees_only_explorable_pages(self):
|
||||
|
@ -128,13 +128,13 @@ class TestExplorerNavView(TestCase, WagtailTestUtils):
|
|||
self.assertEqual(len(response.context['nodes']), 2)
|
||||
# Sam should see the testserver homepage, the example.com homepage, and the Content page,
|
||||
# but should not see Page 2.
|
||||
self.assertEqual(response.context['nodes'][0][0], Page.objects.get(id=2))
|
||||
self.assertEqual(response.context['nodes'][1][0], Page.objects.get(id=4))
|
||||
self.assertEqual(response.context['nodes'][1][1][0][0], Page.objects.get(id=5))
|
||||
self.assertEqual(response.context['nodes'][0][0], Page.objects.get(id=2).specific)
|
||||
self.assertEqual(response.context['nodes'][1][0], Page.objects.get(id=4).specific)
|
||||
self.assertEqual(response.context['nodes'][1][1][0][0], Page.objects.get(id=5).specific)
|
||||
self.assertEqual(len(response.context['nodes'][1][1][0][1]), 1)
|
||||
# page-1 is included in the menu, despite being a leaf node, because Sam has direct
|
||||
# permission on it
|
||||
self.assertEqual(response.context['nodes'][1][1][0][1][0][0], Page.objects.get(id=6))
|
||||
self.assertEqual(response.context['nodes'][1][1][0][1][0][0], Page.objects.get(id=6).specific)
|
||||
self.client.logout()
|
||||
|
||||
self.assertTrue(self.client.login(username='jane', password='password'))
|
||||
|
@ -143,7 +143,7 @@ class TestExplorerNavView(TestCase, WagtailTestUtils):
|
|||
self.assertEqual(response.status_code, 200)
|
||||
self.assertTemplateUsed('wagtailadmin/shared/explorer_nav.html')
|
||||
self.assertEqual(len(response.context['nodes']), 1)
|
||||
self.assertEqual(response.context['nodes'][0][0], Page.objects.get(id=2))
|
||||
self.assertEqual(response.context['nodes'][0][0], Page.objects.get(id=2).specific)
|
||||
self.assertEqual(len(response.context['nodes'][0][1]), 0)
|
||||
|
||||
def test_nonadmin_with_no_page_perms_sees_nothing_in_nav(self):
|
||||
|
|
|
@ -25,6 +25,7 @@ from wagtail.tests.testapp.models import (
|
|||
EventPage, EventPageCarouselItem, FilePage, SimplePage, SingleEventPage, SingletonPage,
|
||||
StandardChild, StandardIndex, TaggedPage)
|
||||
from wagtail.tests.utils import WagtailTestUtils
|
||||
from wagtail.wagtailadmin.views.home import RecentEditsPanel
|
||||
from wagtail.wagtailcore.models import GroupPagePermission, Page, PageRevision, Site
|
||||
from wagtail.wagtailcore.signals import page_published, page_unpublished
|
||||
from wagtail.wagtailsearch.index import SearchField
|
||||
|
@ -3513,6 +3514,20 @@ class TestRecentEditsPanel(TestCase, WagtailTestUtils):
|
|||
response = self.go_to_dashboard_response()
|
||||
self.assertIn('Your most recent edits', response.content.decode('utf-8'))
|
||||
|
||||
def test_panel(self):
|
||||
"""Test if the panel actually returns expected pages """
|
||||
self.client.login(username='bob', password='password')
|
||||
# change a page
|
||||
self.change_something("Bob's edit")
|
||||
# set a user to 'mock' a request
|
||||
self.client.user = get_user_model().objects.get(email='bob@email.com')
|
||||
# get the panel to get the last edits
|
||||
panel = RecentEditsPanel(self.client)
|
||||
# check if the revision is the revision of edited Page
|
||||
self.assertEqual(panel.last_edits[0][0].page, Page.objects.get(pk=self.child_page.id))
|
||||
# check if the page in this list is the specific page of this revision
|
||||
self.assertEqual(panel.last_edits[0][1], Page.objects.get(pk=self.child_page.id).specific)
|
||||
|
||||
|
||||
class TestIssue2994(TestCase, WagtailTestUtils):
|
||||
"""
|
||||
|
|
|
@ -6,7 +6,7 @@ from django.template.loader import render_to_string
|
|||
|
||||
from wagtail.wagtailadmin.site_summary import SiteSummaryPanel
|
||||
from wagtail.wagtailcore import hooks
|
||||
from wagtail.wagtailcore.models import PageRevision, UserPagePermissionsProxy
|
||||
from wagtail.wagtailcore.models import Page, PageRevision, UserPagePermissionsProxy
|
||||
|
||||
|
||||
# Panels for the homepage
|
||||
|
@ -48,7 +48,7 @@ class RecentEditsPanel(object):
|
|||
def __init__(self, request):
|
||||
self.request = request
|
||||
# Last n edited pages
|
||||
self.last_edits = PageRevision.objects.raw(
|
||||
last_edits = PageRevision.objects.raw(
|
||||
"""
|
||||
SELECT wp.* FROM
|
||||
wagtailcore_pagerevision wp JOIN (
|
||||
|
@ -56,6 +56,13 @@ class RecentEditsPanel(object):
|
|||
wagtailcore_pagerevision WHERE user_id = %s GROUP BY page_id ORDER BY max_created_at DESC LIMIT %s
|
||||
) AS max_rev ON max_rev.max_created_at = wp.created_at ORDER BY wp.created_at DESC
|
||||
""", [self.request.user.pk, 5])
|
||||
last_edits = list(last_edits)
|
||||
page_keys = [pr.page.pk for pr in last_edits]
|
||||
specific_pages = Page.objects.filter(pk__in=page_keys).specific()
|
||||
pages = {p.pk: p for p in specific_pages}
|
||||
self.last_edits = [
|
||||
[review, pages.get(review.page.pk)] for review in last_edits
|
||||
]
|
||||
|
||||
def render(self):
|
||||
return render_to_string('wagtailadmin/home/recent_edits.html', {
|
||||
|
|
|
@ -97,7 +97,7 @@ def index(request, parent_page_id=None):
|
|||
paginator, pages = paginate(request, pages, per_page=50)
|
||||
|
||||
return render(request, 'wagtailadmin/pages/index.html', {
|
||||
'parent_page': parent_page,
|
||||
'parent_page': parent_page.specific,
|
||||
'ordering': ordering,
|
||||
'pagination_query_params': "ordering=%s" % ordering,
|
||||
'pages': pages,
|
||||
|
@ -219,18 +219,18 @@ def create(request, content_type_app_name, content_type_model_name, parent_page_
|
|||
# Notifications
|
||||
if is_publishing:
|
||||
if page.go_live_at and page.go_live_at > timezone.now():
|
||||
messages.success(request, _("Page '{0}' created and scheduled for publishing.").format(page.title), buttons=[
|
||||
messages.success(request, _("Page '{0}' created and scheduled for publishing.").format(page.get_admin_display_title()), buttons=[
|
||||
messages.button(reverse('wagtailadmin_pages:edit', args=(page.id,)), _('Edit'))
|
||||
])
|
||||
else:
|
||||
messages.success(request, _("Page '{0}' created and published.").format(page.title), buttons=[
|
||||
messages.success(request, _("Page '{0}' created and published.").format(page.get_admin_display_title()), buttons=[
|
||||
messages.button(page.url, _('View live')),
|
||||
messages.button(reverse('wagtailadmin_pages:edit', args=(page.id,)), _('Edit'))
|
||||
])
|
||||
elif is_submitting:
|
||||
messages.success(
|
||||
request,
|
||||
_("Page '{0}' created and submitted for moderation.").format(page.title),
|
||||
_("Page '{0}' created and submitted for moderation.").format(page.get_admin_display_title()),
|
||||
buttons=[
|
||||
messages.button(reverse('wagtailadmin_pages:view_draft', args=(page.id,)), _('View draft')),
|
||||
messages.button(reverse('wagtailadmin_pages:edit', args=(page.id,)), _('Edit'))
|
||||
|
@ -239,7 +239,7 @@ def create(request, content_type_app_name, content_type_model_name, parent_page_
|
|||
if not send_notification(page.get_latest_revision().id, 'submitted', request.user.pk):
|
||||
messages.error(request, _("Failed to send notifications to moderators"))
|
||||
else:
|
||||
messages.success(request, _("Page '{0}' created.").format(page.title))
|
||||
messages.success(request, _("Page '{0}' created.").format(page.get_admin_display_title()))
|
||||
|
||||
for fn in hooks.get_hooks('after_create_page'):
|
||||
result = fn(request, page)
|
||||
|
@ -345,13 +345,13 @@ def edit(request, page_id):
|
|||
"Revision from {0} of page '{1}' has been scheduled for publishing."
|
||||
).format(
|
||||
previous_revision.created_at.strftime("%d %b %Y %H:%M"),
|
||||
page.title
|
||||
page.get_admin_display_title()
|
||||
)
|
||||
else:
|
||||
message = _(
|
||||
"Page '{0}' has been scheduled for publishing."
|
||||
).format(
|
||||
page.title
|
||||
page.get_admin_display_title()
|
||||
)
|
||||
|
||||
messages.success(request, message, buttons=[
|
||||
|
@ -369,13 +369,13 @@ def edit(request, page_id):
|
|||
"Revision from {0} of page '{1}' has been published."
|
||||
).format(
|
||||
previous_revision.created_at.strftime("%d %b %Y %H:%M"),
|
||||
page.title
|
||||
page.get_admin_display_title()
|
||||
)
|
||||
else:
|
||||
message = _(
|
||||
"Page '{0}' has been published."
|
||||
).format(
|
||||
page.title
|
||||
page.get_admin_display_title()
|
||||
)
|
||||
|
||||
messages.success(request, message, buttons=[
|
||||
|
@ -394,7 +394,7 @@ def edit(request, page_id):
|
|||
message = _(
|
||||
"Page '{0}' has been submitted for moderation."
|
||||
).format(
|
||||
page.title
|
||||
page.get_admin_display_title()
|
||||
)
|
||||
|
||||
messages.success(request, message, buttons=[
|
||||
|
@ -417,14 +417,14 @@ def edit(request, page_id):
|
|||
message = _(
|
||||
"Page '{0}' has been replaced with revision from {1}."
|
||||
).format(
|
||||
page.title,
|
||||
page.get_admin_display_title(),
|
||||
previous_revision.created_at.strftime("%d %b %Y %H:%M")
|
||||
)
|
||||
else:
|
||||
message = _(
|
||||
"Page '{0}' has been updated."
|
||||
).format(
|
||||
page.title
|
||||
page.get_admin_display_title()
|
||||
)
|
||||
|
||||
messages.success(request, message)
|
||||
|
@ -501,7 +501,7 @@ def delete(request, page_id):
|
|||
parent_id = page.get_parent().id
|
||||
page.delete()
|
||||
|
||||
messages.success(request, _("Page '{0}' deleted.").format(page.title))
|
||||
messages.success(request, _("Page '{0}' deleted.").format(page.get_admin_display_title()))
|
||||
|
||||
for fn in hooks.get_hooks('after_delete_page'):
|
||||
result = fn(request, page)
|
||||
|
@ -673,7 +673,7 @@ def unpublish(request, page_id):
|
|||
if user_perms.for_page(live_descendant_page).can_unpublish():
|
||||
live_descendant_page.unpublish()
|
||||
|
||||
messages.success(request, _("Page '{0}' unpublished.").format(page.title), buttons=[
|
||||
messages.success(request, _("Page '{0}' unpublished.").format(page.get_admin_display_title()), buttons=[
|
||||
messages.button(reverse('wagtailadmin_pages:edit', args=(page.id,)), _('Edit'))
|
||||
])
|
||||
|
||||
|
@ -735,7 +735,7 @@ def move_confirm(request, page_to_move_id, destination_id):
|
|||
# so don't bother to catch InvalidMoveToDescendant
|
||||
page_to_move.move(destination, pos='last-child')
|
||||
|
||||
messages.success(request, _("Page '{0}' moved.").format(page_to_move.title), buttons=[
|
||||
messages.success(request, _("Page '{0}' moved.").format(page_to_move.get_admin_display_title()), buttons=[
|
||||
messages.button(reverse('wagtailadmin_pages:edit', args=(page_to_move.id,)), _('Edit'))
|
||||
])
|
||||
|
||||
|
@ -834,10 +834,10 @@ def copy(request, page_id):
|
|||
if form.cleaned_data.get('copy_subpages'):
|
||||
messages.success(
|
||||
request,
|
||||
_("Page '{0}' and {1} subpages copied.").format(page.title, new_page.get_descendants().count())
|
||||
_("Page '{0}' and {1} subpages copied.").format(page.get_admin_display_title(), new_page.get_descendants().count())
|
||||
)
|
||||
else:
|
||||
messages.success(request, _("Page '{0}' copied.").format(page.title))
|
||||
messages.success(request, _("Page '{0}' copied.").format(page.get_admin_display_title()))
|
||||
|
||||
# Redirect to explore of parent page
|
||||
if next_url:
|
||||
|
@ -887,12 +887,12 @@ def approve_moderation(request, revision_id):
|
|||
raise PermissionDenied
|
||||
|
||||
if not revision.submitted_for_moderation:
|
||||
messages.error(request, _("The page '{0}' is not currently awaiting moderation.").format(revision.page.title))
|
||||
messages.error(request, _("The page '{0}' is not currently awaiting moderation.").format(revision.page.get_admin_display_title()))
|
||||
return redirect('wagtailadmin_home')
|
||||
|
||||
if request.method == 'POST':
|
||||
revision.approve_moderation()
|
||||
messages.success(request, _("Page '{0}' published.").format(revision.page.title), buttons=[
|
||||
messages.success(request, _("Page '{0}' published.").format(revision.page.get_admin_display_title()), buttons=[
|
||||
messages.button(revision.page.url, _('View live')),
|
||||
messages.button(reverse('wagtailadmin_pages:edit', args=(revision.page.id,)), _('Edit'))
|
||||
])
|
||||
|
@ -908,12 +908,12 @@ def reject_moderation(request, revision_id):
|
|||
raise PermissionDenied
|
||||
|
||||
if not revision.submitted_for_moderation:
|
||||
messages.error(request, _("The page '{0}' is not currently awaiting moderation.").format(revision.page.title))
|
||||
messages.error(request, _("The page '{0}' is not currently awaiting moderation.").format(revision.page.get_admin_display_title()))
|
||||
return redirect('wagtailadmin_home')
|
||||
|
||||
if request.method == 'POST':
|
||||
revision.reject_moderation()
|
||||
messages.success(request, _("Page '{0}' rejected for publication.").format(revision.page.title), buttons=[
|
||||
messages.success(request, _("Page '{0}' rejected for publication.").format(revision.page.get_admin_display_title()), buttons=[
|
||||
messages.button(reverse('wagtailadmin_pages:edit', args=(revision.page.id,)), _('Edit'))
|
||||
])
|
||||
if not send_notification(revision.id, 'rejected', request.user.pk):
|
||||
|
@ -929,7 +929,7 @@ def preview_for_moderation(request, revision_id):
|
|||
raise PermissionDenied
|
||||
|
||||
if not revision.submitted_for_moderation:
|
||||
messages.error(request, _("The page '{0}' is not currently awaiting moderation.").format(revision.page.title))
|
||||
messages.error(request, _("The page '{0}' is not currently awaiting moderation.").format(revision.page.get_admin_display_title()))
|
||||
return redirect('wagtailadmin_home')
|
||||
|
||||
page = revision.as_page_object()
|
||||
|
@ -955,7 +955,7 @@ def lock(request, page_id):
|
|||
page.locked = True
|
||||
page.save()
|
||||
|
||||
messages.success(request, _("Page '{0}' is now locked.").format(page.title))
|
||||
messages.success(request, _("Page '{0}' is now locked.").format(page.get_admin_display_title()))
|
||||
|
||||
# Redirect
|
||||
redirect_to = request.POST.get('next', None)
|
||||
|
@ -979,7 +979,7 @@ def unlock(request, page_id):
|
|||
page.locked = False
|
||||
page.save()
|
||||
|
||||
messages.success(request, _("Page '{0}' is now unlocked.").format(page.title))
|
||||
messages.success(request, _("Page '{0}' is now unlocked.").format(page.get_admin_display_title()))
|
||||
|
||||
# Redirect
|
||||
redirect_to = request.POST.get('next', None)
|
||||
|
|
|
@ -77,10 +77,10 @@ def page_listing_buttons(page, page_perms, is_parent=False):
|
|||
if page_perms.can_add_subpage():
|
||||
if is_parent:
|
||||
yield Button(_('Add child page'), reverse('wagtailadmin_pages:add_subpage', args=[page.id]),
|
||||
attrs={'title': _("Add a child page to '{0}' ".format(page.title))}, classes={'button', 'button-small', 'bicolor', 'icon', 'white', 'icon-plus'}, priority=40)
|
||||
attrs={'title': _("Add a child page to '{0}' ".format(page.get_admin_display_title()))}, classes={'button', 'button-small', 'bicolor', 'icon', 'white', 'icon-plus'}, priority=40)
|
||||
else:
|
||||
yield PageListingButton(_('Add child page'), reverse('wagtailadmin_pages:add_subpage', args=[page.id]),
|
||||
attrs={'title': _("Add a child page to '{0}' ".format(page.title))}, priority=40)
|
||||
attrs={'title': _("Add a child page to '{0}' ".format(page.get_admin_display_title()))}, priority=40)
|
||||
|
||||
yield ButtonWithDropdownFromHook(
|
||||
_('More'),
|
||||
|
|
|
@ -673,6 +673,12 @@ class Page(six.with_metaclass(PageBase, AbstractPage, index.Indexed, Clusterable
|
|||
else:
|
||||
raise Http404
|
||||
|
||||
def get_admin_display_title(self):
|
||||
"""
|
||||
Return the title for this page as it should appear in the admin backend.
|
||||
"""
|
||||
return self.title
|
||||
|
||||
def save_revision(self, user=None, submitted_for_moderation=False, approved_go_live_at=None, changed=True):
|
||||
self.full_clean()
|
||||
|
||||
|
|
|
@ -83,6 +83,10 @@ class TestValidation(TestCase):
|
|||
homepage.add_child(instance=christmas_page)
|
||||
self.assertTrue(Page.objects.filter(id=christmas_page.id).exists())
|
||||
|
||||
def test_get_admin_display_title(self):
|
||||
homepage = Page.objects.get(url_path='/home/')
|
||||
self.assertEquals(homepage.title, homepage.get_admin_display_title())
|
||||
|
||||
|
||||
@override_settings(ALLOWED_HOSTS=['localhost', 'events.example.com', 'about.example.com', 'unknown.site.com'])
|
||||
class TestSiteRouting(TestCase):
|
||||
|
|
Ładowanie…
Reference in New Issue