Call 'specific' attribute when fetching page

Get the specific implementation of a page, this shows the correct
get_admin_display_title on the delete confirmation page.
pull/4380/merge
Kim Chee Leong 2018-03-14 16:07:55 +01:00 zatwierdzone przez Matt Westcott
rodzic 07bcf45027
commit 2fdb924b56
5 zmienionych plików z 13 dodań i 1 usunięć

Wyświetl plik

@ -23,6 +23,7 @@ Changelog
* Fix: Correct dropdown arrow styling in Firefox, IE11 (Janneke Janssen, Alexs Mathilda)
* Fix: Password reset no indicates specific validation errors on certain password restrictions (Lucas Moeskops)
* Fix: Fix a typo within documentation for pages (DanAtShenTech)
* Fix: Confirmation page on page deletion now respects custom `get_admin_display_title` methods (Kim Chee Leong)
2.0.1 (xx.xx.xxxx) - IN DEVELOPMENT

Wyświetl plik

@ -37,6 +37,7 @@ Bug fixes
* Correct dropdown arrow styling in Firefox, IE11 (Janneke Janssen, Alexs Mathilda)
* Password reset no indicates specific validation errors on certain password restrictions (Lucas Moeskops)
* Fix a typo within documentation for pages (DanAtShenTech)
* Confirmation page on page deletion now respects custom ``get_admin_display_title`` methods (Kim Chee Leong)
Upgrade considerations

Wyświetl plik

@ -2033,6 +2033,13 @@ class TestPageDelete(TestCase, WagtailTestUtils):
# deletion should not actually happen on GET
self.assertTrue(SimplePage.objects.filter(id=self.child_page.id).exists())
def test_page_delete_specific_admin_title(self):
response = self.client.get(reverse('wagtailadmin_pages:delete', args=(self.child_page.id, )))
self.assertEqual(response.status_code, 200)
# The admin_display_title specific to ChildPage is shown on the delete confirmation page.
self.assertContains(response, self.child_page.get_admin_display_title())
def test_page_delete_bad_permissions(self):
# Remove privileges from user
self.user.is_superuser = False

Wyświetl plik

@ -517,7 +517,7 @@ def edit(request, page_id):
def delete(request, page_id):
page = get_object_or_404(Page, id=page_id)
page = get_object_or_404(Page, id=page_id).specific
if not page.permissions_for_user(request.user).can_delete():
raise PermissionDenied

Wyświetl plik

@ -141,6 +141,9 @@ class SimplePage(Page):
FieldPanel('content'),
]
def get_admin_display_title(self):
return "%s (simple page)" % super().get_admin_display_title()
# Page with Excluded Fields when copied
class PageWithExcludedCopyField(Page):