backoffice: always display multi actions if roles are okay (#36760)

This commit is contained in:
Frédéric Péters 2019-10-08 09:37:51 +02:00
parent d3eb54b88c
commit 91087f529c
1 changed files with 6 additions and 1 deletions

View File

@ -1331,11 +1331,16 @@ class FormPage(Directory):
return ''
def get_multi_actions(self, user):
# filter global manual actions to get those that can be run by the
# user, either because of actual roles, or because the action is
# accessible to functions.
global_actions = self.formdef.workflow.get_global_manual_actions()
workflow_roles = self.formdef.workflow.roles or {}
mass_actions = []
for action_dict in global_actions:
action_dict['roles'] = [x for x in user.get_roles() if x in action_dict.get('roles') or []]
if action_dict['roles']:
# action is accessible with user roles, remove mentions of functions
action_dict['functions'] = []
if action_dict['functions'] or action_dict['roles']:
mass_actions.append(action_dict)
return mass_actions