Skip to content

Commit

Permalink
Use get_admin_display_title in PageChooserPanel
Browse files Browse the repository at this point in the history
  • Loading branch information
SaptakS authored and gasman committed Sep 28, 2020
1 parent 0c68159 commit 61e8173
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Changelog
* Fix: Revise `edit_handler` bind order in ModelAdmin views and fix duplicate form instance creation (Jérôme Lebleu)
* Fix: Properly distinguish child blocks when comparing revisions with nested StreamBlocks (Martin Mena)
* Fix: Correctly handle Turkish 'İ' characters in client-side slug generation (Matt Westcott)
* Fix: Page chooser widgets now reflect custom ``get_admin_display_title`` methods (Saptak Sengupta)


2.10.2 (25.09.2020)
Expand Down
1 change: 1 addition & 0 deletions docs/releases/2.11.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ Bug fixes
* Revise ``edit_handler`` bind order in ModelAdmin views and fix duplicate form instance creation (Jérôme Lebleu)
* Properly distinguish child blocks when comparing revisions with nested StreamBlocks (Martin Mena)
* Correctly handle Turkish 'İ' characters in client-side slug generation (Matt Westcott)
* Page chooser widgets now reflect custom ``get_admin_display_title`` methods (Saptak Sengupta)


Upgrade considerations
Expand Down
2 changes: 1 addition & 1 deletion wagtail/admin/static_src/wagtailadmin/js/page-chooser.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function createPageChooser(id, pageTypes, openAtParentId, canChooseRoot, userPer
pageChosen: function(pageData) {
input.val(pageData.id);
openAtParentId = pageData.parentId;
pageTitle.text(pageData.title);
pageTitle.text(pageData.adminTitle);
chooserElement.removeClass('blank');
editLink.attr('href', pageData.editUrl);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<div class="title-wrapper">
{% if page.can_choose %}
<a class="choose-page" href="#{{ page.id|unlocalize }}" data-id="{{ page.id|unlocalize }}" data-title="{{ page.title }}" data-url="{{ page.url }}" data-parent-id="{{ page.get_parent.id|unlocalize }}" data-edit-url="{% url 'wagtailadmin_pages:edit' page.id %}">{{ page.get_admin_display_title }}</a>
<a class="choose-page" href="#{{ page.id|unlocalize }}" data-id="{{ page.id|unlocalize }}" data-title="{{ page.title }}" data-admin-title="{{ page.get_admin_display_title }}" data-url="{{ page.url }}" data-parent-id="{{ page.get_parent.id|unlocalize }}" data-edit-url="{% url 'wagtailadmin_pages:edit' page.id %}">{{ page.get_admin_display_title }}</a>
{% else %}
{{ page.get_admin_display_title }}
{% endif %}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{% extends "wagtailadmin/widgets/chooser.html" %}

{% block chosen_state_view %}
<span class="title">{{ page.get_admin_display_title }}</span>
<span class="title">{{ page.specific.get_admin_display_title }}</span>
{% endblock %}

{% block edit_chosen_item_url %}{% if page %}{% url 'wagtailadmin_pages:edit' page.id %}{% endif %}{% endblock %}
2 changes: 2 additions & 0 deletions wagtail/admin/tests/test_widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ def test_render_html_with_value(self):

html = widget.render_html('test', self.child_page, {})
self.assertInHTML("""<input name="test" type="hidden" value="%d" />""" % self.child_page.id, html)
# SimplePage has a custom get_admin_display_title method which should be reflected here
self.assertInHTML("foobarbaz (simple page)", html)

def test_render_js_init_with_value(self):
widget = widgets.AdminPageChooser()
Expand Down

0 comments on commit 61e8173

Please sign in to comment.