0
0
mirror of https://github.com/wagtail/wagtail.git synced 2024-11-29 17:36:49 +01:00

Fix incorrect override of PagePermissionHelper.user_can_unpublish_obj() in ModelAdmin

This commit is contained in:
Sébastien Corbin 2023-07-05 11:15:19 +02:00 committed by Sage Abdullah
parent ccc44035d9
commit 853aad4305
No known key found for this signature in database
GPG Key ID: EB1A33CC51CC0217
4 changed files with 26 additions and 1 deletions

View File

@ -38,6 +38,7 @@ Changelog
* Fix: Remove unnecessary usage of `innerHTML` when modifying DOM content (LB (Ben) Johnston)
* Fix: Avoid `ValueError` when extending `PagesAPIViewSet` and setting `meta_fields` to an empty list (Henry Harutyunyan, Alex Morega)
* Fix: Improve accessibility for header search, remove autofocus on page load, advise screen readers that content has changed when results update (LB (Ben) Johnston)
* Fix: Fix incorrect override of `PagePermissionHelper.user_can_unpublish_obj()` in ModelAdmin (Sébastien Corbin)
* Docs: Document how to add non-ModelAdmin views to a `ModelAdminGroup` (Onno Timmerman)
* Docs: Document how to add StructBlock data to a StreamField (Ramon Wenger)
* Docs: Update ReadTheDocs settings to v2 to resolve urllib3 issue in linkcheck extension (Thibaud Colas)

View File

@ -69,6 +69,7 @@ Thank you to Damilola for his work, and to Google for sponsoring this project.
* Remove unnecessary usage of `innerHTML` when modifying DOM content (LB (Ben) Johnston)
* Avoid `ValueError` when extending `PagesAPIViewSet` and setting `meta_fields` to an empty list (Henry Harutyunyan, Alex Morega)
* Improve accessibility for header search, remove autofocus on page load, advise screen readers that content has changed when results update (LB (Ben) Johnston)
* Fix incorrect override of `PagePermissionHelper.user_can_unpublish_obj()` in ModelAdmin (Sébastien Corbin)
### Documentation

View File

@ -177,7 +177,7 @@ class PagePermissionHelper(PermissionHelper):
perms = obj.permissions_for_user(user)
return perms.can_delete()
def user_can_publish_obj(self, user, obj):
def user_can_unpublish_obj(self, user, obj):
perms = obj.permissions_for_user(user)
return obj.live and perms.can_unpublish()

View File

@ -82,6 +82,29 @@ class TestIndexView(WagtailTestUtils, TestCase):
root_page = Page.objects.get(depth=1)
self.assertNotIn(root_page, response.context["paginator"].object_list)
def test_page_buttons_are_shown(self):
response = self.get()
self.assertContains(
response,
'<a href="/admin/tests/eventpage/inspect/12/" class="button button-secondary button-small" title="Inspect this event page">Inspect</a>',
)
self.assertContains(
response,
'<a href="/admin/pages/12/edit/?next=/admin/tests/eventpage/" class="button button-secondary button-small" title="Edit this event page">Edit</a>',
)
self.assertContains(
response,
'<a href="/admin/pages/12/copy/?next=/admin/tests/eventpage/" class="button button-small" title="Copy this event page">Copy</a>',
)
self.assertContains(
response,
'<a href="/admin/pages/12/unpublish/?next=/admin/tests/eventpage/" class="button button-small" title="Unpublish this event page">Unpublish</a>',
)
self.assertContains(
response,
'<a href="/admin/pages/12/delete/?next=/admin/tests/eventpage/" class="button no button-small" title="Delete this event page">Delete</a>',
)
class TestExcludeFromExplorer(WagtailTestUtils, TestCase):
fixtures = ["modeladmintest_test.json"]