diff --git a/CONTRIBUTORS.rst b/CONTRIBUTORS.rst index 95caf01fe..6e1def7ab 100644 --- a/CONTRIBUTORS.rst +++ b/CONTRIBUTORS.rst @@ -279,6 +279,7 @@ Contributors * Dan Dietz * Michael Harrison * Todd Dembrey +* Sebastian Brestin Translators =========== diff --git a/wagtail/admin/wagtail_hooks.py b/wagtail/admin/wagtail_hooks.py index 47c9c4ada..dc26c9c81 100644 --- a/wagtail/admin/wagtail_hooks.py +++ b/wagtail/admin/wagtail_hooks.py @@ -153,7 +153,7 @@ def page_listing_more_buttons(page, page_perms, is_parent=False): attrs={"title": _("Move page '{title}'").format(title=page.get_admin_display_title())}, priority=10 ) - if not page.is_root(): + if page_perms.can_copy(): yield Button( _('Copy'), reverse('wagtailadmin_pages:copy', args=[page.id]), @@ -174,7 +174,7 @@ def page_listing_more_buttons(page, page_perms, is_parent=False): attrs={'title': _("Unpublish page '{title}'").format(title=page.get_admin_display_title())}, priority=40 ) - if not page.is_root(): + if page_perms.can_view_revisions(): yield Button( _('Revisions'), reverse('wagtailadmin_pages:revisions_index', args=[page.id]), diff --git a/wagtail/core/models.py b/wagtail/core/models.py index c1518c9d6..747ffc192 100644 --- a/wagtail/core/models.py +++ b/wagtail/core/models.py @@ -1773,6 +1773,9 @@ class PagePermissionTester: """ return self.can_delete() + def can_copy(self): + return not self.page_is_root + def can_move_to(self, destination): # reject the logically impossible cases first if self.page == destination or destination.is_descendant_of(self.page): @@ -1831,6 +1834,9 @@ class PagePermissionTester: return True + def can_view_revisions(self): + return not self.page_is_root + class BaseViewRestriction(models.Model): NONE = 'none'