mirror of
https://github.com/wagtail/wagtail.git
synced 2024-12-01 11:41:20 +01:00
Apply permission check on workflow tasks menu item
This commit is contained in:
parent
61db62d125
commit
8e1463f503
@ -25,7 +25,8 @@ from wagtail.admin.viewsets import viewsets
|
||||
from wagtail.admin.widgets import Button, ButtonWithDropdownFromHook, PageListingButton
|
||||
from wagtail.core import hooks
|
||||
from wagtail.core.models import UserPagePermissionsProxy
|
||||
from wagtail.core.permissions import collection_permission_policy, workflow_permission_policy
|
||||
from wagtail.core.permissions import (
|
||||
collection_permission_policy, task_permission_policy, workflow_permission_policy)
|
||||
from wagtail.core.whitelist import allow_without_attributes, attribute_rule, check_url
|
||||
|
||||
|
||||
@ -108,6 +109,13 @@ class WorkflowsMenuItem(MenuItem):
|
||||
)
|
||||
|
||||
|
||||
class WorkflowTasksMenuItem(MenuItem):
|
||||
def is_shown(self, request):
|
||||
return task_permission_policy.user_has_any_permission(
|
||||
request.user, ['add', 'change', 'delete']
|
||||
)
|
||||
|
||||
|
||||
@hooks.register('register_settings_menu_item')
|
||||
def register_workflows_menu_item():
|
||||
return WorkflowsMenuItem(_('Workflows'), reverse('wagtailadmin_workflows:index'), icon_name='tasks', order=100)
|
||||
@ -115,7 +123,7 @@ def register_workflows_menu_item():
|
||||
|
||||
@hooks.register('register_settings_menu_item')
|
||||
def register_workflow_tasks_menu_item():
|
||||
return MenuItem(_('Workflow tasks'), reverse('wagtailadmin_workflows:task_index'), icon_name='thumbtack', order=150)
|
||||
return WorkflowTasksMenuItem(_('Workflow tasks'), reverse('wagtailadmin_workflows:task_index'), icon_name='thumbtack', order=150)
|
||||
|
||||
|
||||
@hooks.register('register_page_listing_buttons')
|
||||
|
Loading…
Reference in New Issue
Block a user