Skip to content

Commit

Permalink
Use get_admin_display_title in admin
Browse files Browse the repository at this point in the history
  • Loading branch information
Henk-Jan van Hasselaar authored and gasman committed Oct 13, 2016
1 parent 9710c29 commit 8a3c47f
Show file tree
Hide file tree
Showing 42 changed files with 144 additions and 107 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ Contributors
* Mattias Loverot
* Ricky Robinett
* Axel Haustant
* Henk-Jan van Hasselaar

Translators
===========
Expand Down
2 changes: 2 additions & 0 deletions docs/reference/pages/model_reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions docs/releases/1.8.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion wagtail/contrib/modeladmin/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))


Expand Down
2 changes: 1 addition & 1 deletion wagtail/wagtailadmin/navigation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ <h2>{% trans 'Pages awaiting moderation' %}</h2>
<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 %}
Expand All @@ -44,15 +44,15 @@ <h2>
</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 }}
</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>
by {{ revision.user.get_full_name|default:revision.user.get_username }}
</td>
</td>
</tr>
{% endfor %}
</tbody>
Expand Down
22 changes: 11 additions & 11 deletions wagtail/wagtailadmin/templates/wagtailadmin/home/recent_edits.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,33 +15,33 @@ <h2>{% trans "Your most recent edits" %}</h2>
</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 %}
</tbody>
</table>
</section>
</div>
{% endif %}
{% endif %}
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}
Original file line number Diff line number Diff line change
@@ -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 %}
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}
Original file line number Diff line number Diff line change
@@ -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 %}
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -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 %}
Expand Down
Original file line number Diff line number Diff line change
@@ -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>
Expand Down
Original file line number Diff line number Diff line change
@@ -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">
Expand Down
Original file line number Diff line number Diff line change
@@ -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>
Expand Down
4 changes: 2 additions & 2 deletions wagtail/wagtailadmin/templates/wagtailadmin/pages/copy.html
Original file line number Diff line number Diff line change
@@ -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>
Expand Down
4 changes: 2 additions & 2 deletions wagtail/wagtailadmin/templates/wagtailadmin/pages/edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}
Expand All @@ -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" %}
Expand Down
Original file line number Diff line number Diff line change
@@ -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 %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}
Expand All @@ -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 %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@

<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>
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
<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>

0 comments on commit 8a3c47f

Please sign in to comment.