mirror of
https://github.com/Hopiu/wagtail.git
synced 2026-05-10 00:06:13 +00:00
Make get_admin_display_title fall back on live title
This commit is contained in:
parent
bafdedd1d1
commit
acee90bf1e
2 changed files with 13 additions and 1 deletions
|
|
@ -661,7 +661,9 @@ class Page(six.with_metaclass(PageBase, AbstractPage, index.Indexed, Clusterable
|
|||
override this if you wish to display extra contextual information about the page,
|
||||
such as language. By default, returns ``draft_title``.
|
||||
"""
|
||||
return self.draft_title
|
||||
# Fall back on title if draft_title is blank (which may happen if the page was created
|
||||
# in a fixture or migration that didn't explicitly handle draft_title)
|
||||
return self.draft_title or self.title
|
||||
|
||||
def save_revision(self, user=None, submitted_for_moderation=False, approved_go_live_at=None, changed=True):
|
||||
self.full_clean()
|
||||
|
|
|
|||
|
|
@ -90,6 +90,16 @@ class TestValidation(TestCase):
|
|||
homepage = Page.objects.get(url_path='/home/')
|
||||
self.assertEqual(homepage.draft_title, homepage.get_admin_display_title())
|
||||
|
||||
def test_get_admin_display_title_with_blank_draft_title(self):
|
||||
# Display title should fall back on the live title if draft_title is blank;
|
||||
# this can happen if the page was created through fixtures or migrations that
|
||||
# didn't explicitly account for draft_title
|
||||
# (since draft_title doesn't get populated automatically on save in those cases)
|
||||
Page.objects.filter(url_path='/home/').update(title='live title', draft_title='')
|
||||
homepage = Page.objects.get(url_path='/home/')
|
||||
|
||||
self.assertEqual(homepage.get_admin_display_title(), 'live title')
|
||||
|
||||
def test_draft_title_is_autopopulated(self):
|
||||
homepage = Page.objects.get(url_path='/home/')
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue