Commit 84a5644f authored by iv's avatar iv

ERP5Workflow: fix typo (forgotten 'not') + add isGuarded method

parent 8a136576
...@@ -350,10 +350,7 @@ class Workflow(IdAsReferenceMixin("", "prefix"), XMLObject): ...@@ -350,10 +350,7 @@ class Workflow(IdAsReferenceMixin("", "prefix"), XMLObject):
workflow_title = self.getTitle() workflow_title = self.getTitle()
for worklist_value in self.getWorklistValueList(): for worklist_value in self.getWorklistValueList():
action_box_name = worklist_value.getActionName() action_box_name = worklist_value.getActionName()
is_guarded = (worklist_value.getGuardRoleList() or is_guarded = worklist_value.isGuarded()
worklist_value.getGuardGroupList() or
worklist_value.getGuardPermissionList() or
worklist_value.getGuardExpression().text)
guard_role_list = worklist_value.getGuardRoleList() guard_role_list = worklist_value.getGuardRoleList()
if action_box_name: if action_box_name:
variable_match = {} variable_match = {}
...@@ -380,9 +377,11 @@ class Workflow(IdAsReferenceMixin("", "prefix"), XMLObject): ...@@ -380,9 +377,11 @@ class Workflow(IdAsReferenceMixin("", "prefix"), XMLObject):
continue continue
is_permitted_worklist = 0 is_permitted_worklist = 0
if is_guarded: if not is_guarded:
is_permitted_worklist = 1 is_permitted_worklist = 1
elif (not check_guard or worklist_value.checkGuard(security_manager, self, portal, check_roles=False)): elif not check_guard or worklist_value.checkGuard(security_manager,
self, portal,
check_roles=False):
is_permitted_worklist = 1 is_permitted_worklist = 1
variable_match[SECURITY_PARAMETER_ID] = guard_role_list variable_match[SECURITY_PARAMETER_ID] = guard_role_list
......
...@@ -30,6 +30,10 @@ class GuardableMixin(object): ...@@ -30,6 +30,10 @@ class GuardableMixin(object):
security = ClassSecurityInfo() security = ClassSecurityInfo()
security.declareObjectProtected(ManagePortal) security.declareObjectProtected(ManagePortal)
def isGuarded(self):
return self.guard_expression and self.guard_group and \
self.guard_permission and guard_role
def checkGuard(self, security_manager, workflow, current_object, check_roles=True, **kw): def checkGuard(self, security_manager, workflow, current_object, check_roles=True, **kw):
"""Checks conditions in this guard. """Checks conditions in this guard.
""" """
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment