Commit 7bf42b1a authored by iv's avatar iv

ERP5Workflow: change getGuard(Role/Permission/Group) to getGuard...List

Adding List to the end of the getter of a given property will return
an instance of type list.
parent 29bb558d
......@@ -95,9 +95,9 @@ class Interaction(IdAsReferenceMixin('interaction_', "prefix"), XMLObject):
return res
def getGuard(self):
if self.getGuardRole() is None and\
self.getGuardPermission() is None and\
self.getGuardGroup() is None and\
if self.getGuardRoleList() is None and\
self.getGuardPermissionList() is None and\
self.getGuardGroupList() is None and\
self.getGuardExpression() is None and\
self.guard is None:
return Guard().__of__(self)
......@@ -107,11 +107,11 @@ class Interaction(IdAsReferenceMixin('interaction_', "prefix"), XMLObject):
def generateGuard(self):
self.guard = Guard()
if self.getGuardRole() is not None:
self.guard.roles = self.getGuardRole()
if self.getGuardPermission() is not None:
self.guard.permissions = self.getGuardPermission()
if self.getGuardGroup() is not None:
self.guard.groups = self.getGuardGroup()
if self.getGuardRoleList() is not None:
self.guard.roles = self.getGuardRoleList()
if self.getGuardPermissionList() is not None:
self.guard.permissions = self.getGuardPermissionList()
if self.getGuardGroupList() is not None:
self.guard.groups = self.getGuardGroupList()
if self.getGuardExpression() is not None:
self.guard.expr = Expression(self.getGuardExpression())
......@@ -100,11 +100,11 @@ class Transition(IdAsReferenceMixin("transition_", "prefix"), XMLObject):
def generateGuard(self):
if self.guard is None:
self.guard = Guard()
if self.getGuardRole() is not None:
self.guard.roles = self.getGuardRole()
if self.getGuardPermission() is not None:
self.guard.permissions = self.getGuardPermission()
if self.getGuardGroup() is not None:
self.guard.groups = self.getGuardGroup()
if self.getGuardRoleList() is not None:
self.guard.roles = self.getGuardRoleList()
if self.getGuardPermissionList() is not None:
self.guard.permissions = self.getGuardPermissionList()
if self.getGuardGroupList() is not None:
self.guard.groups = self.getGuardGroupList()
if self.getGuardExpression() is not None:
self.guard.expr = Expression(self.getGuardExpression())
......@@ -850,11 +850,11 @@ class Workflow(IdAsReferenceMixin("", "prefix"), XMLObject):
for property_id in sorted(transition_prop_id_to_show):
if property_id in ('roles', 'groups', 'permissions', 'expr',):
if property_id == 'roles':
property_value = tdef.getGuardRole()
property_value = tdef.getGuardRoleList()
if property_id == 'groups':
property_value = tdef.getGuardGroup()
property_value = tdef.getGuardGroupList()
if property_id == 'permissions':
property_value = tdef.getGuardPermission()
property_value = tdef.getGuardPermissionList()
if property_id == 'expr':
property_value = tdef.getGuardExpression()
if property_value is None or property_value == [] or property_value == ():
......@@ -949,11 +949,11 @@ class Workflow(IdAsReferenceMixin("", "prefix"), XMLObject):
# show guard configuration:
if property_id in ('roles', 'groups', 'permissions', 'expr',):
if property_id == 'roles':
property_value = qdef.getGuardRole()
property_value = qdef.getGuardRoleList()
if property_id == 'groups':
property_value = qdef.getGuardGroup()
property_value = qdef.getGuardGroupList()
if property_id == 'permissions':
property_value = qdef.getGuardPermission()
property_value = qdef.getGuardPermissionList()
if property_id == 'expr':
property_value = qdef.getGuardExpression()
if property_value is not None:
......
......@@ -72,9 +72,9 @@ class WorkflowVariable(IdAsReferenceMixin("variable_", "prefix"), XMLObject):
return res
def getInfoGuard(self):
if self.getGuardRole() is None and\
self.getGuardPermission() is None and\
self.getGuardGroup() is None and\
if self.getGuardRoleList() is None and\
self.getGuardPermissionList() is None and\
self.getGuardGroupList() is None and\
self.getGuardExpression() is None and\
self.info_guard is None:
return Guard().__of__(self)
......@@ -84,11 +84,11 @@ class WorkflowVariable(IdAsReferenceMixin("variable_", "prefix"), XMLObject):
def generateInfoGuard(self):
self.info_guard = Guard()
if self.getGuardRole() is not None:
self.info_guard.roles = self.getGuardRole()
if self.getGuardPermission() is not None:
self.info_guard.permissions = self.getGuardPermission()
if self.getGuardGroup() is not None:
self.info_guard.groups = self.getGuardGroup()
if self.getGuardRoleList() is not None:
self.info_guard.roles = self.getGuardRoleList()
if self.getGuardPermissionList() is not None:
self.info_guard.permissions = self.getGuardPermissionList()
if self.getGuardGroupList() is not None:
self.info_guard.groups = self.getGuardGroupList()
if self.getGuardExpression() is not None:
self.info_guard.expr = Expression(self.getGuardExpression())
......@@ -85,9 +85,9 @@ class Worklist(IdAsReferenceMixin("worklist_", "prefix"), XMLObject):
return res
def getGuard(self):
if self.getGuardRole() is None and\
self.getGuardPermission() is None and\
self.getGuardGroup() is None and\
if self.getGuardRoleList() is None and\
self.getGuardPermissionList() is None and\
self.getGuardGroupList() is None and\
self.getGuardExpression() is None and\
self.guard is None:
return Guard().__of__(self)
......@@ -97,12 +97,12 @@ class Worklist(IdAsReferenceMixin("worklist_", "prefix"), XMLObject):
def generateGuard(self):
self.guard = Guard()
if self.getGuardRole() is not None:
self.guard.roles = self.getGuardRole()
if self.getGuardPermission() is not None:
self.guard.permissions = self.getGuardPermission()
if self.getGuardGroup() is not None:
self.guard.groups = self.getGuardGroup()
if self.getGuardRoleList() is not None:
self.guard.roles = self.getGuardRoleList()
if self.getGuardPermissionList() is not None:
self.guard.permissions = self.getGuardPermissionList()
if self.getGuardGroupList() is not None:
self.guard.groups = self.getGuardGroupList()
if self.getGuardExpression() is not None:
self.guard.expr = Expression(self.getGuardExpression())
......
......@@ -328,11 +328,11 @@ class WorkflowTool(BaseTool, OriginalWorkflowTool):
# configure guard
if tdef.guard:
transition.guard = tdef.guard
transition.setRoleList(tdef.guard.roles)
transition.setPermissionList(tdef.guard.permissions)
transition.setGroupList(tdef.guard.groups)
transition.setGuardRoleList(tdef.guard.roles)
transition.setGuardPermissionList(tdef.guard.permissions)
transition.setGuardGroupList(tdef.guard.groups)
if tdef.guard.expr is not None:
transition.setExpression(tdef.guard.expr.text)
transition.setGuardExpression(tdef.guard.expr.text)
# create states (portal_type = State)
for sid in dc_workflow.states:
sdef = dc_workflow.states.get(sid)
......@@ -410,7 +410,7 @@ class WorkflowTool(BaseTool, OriginalWorkflowTool):
if isinstance(values, Expression):
worklist_variable_value.setVariableExpression(values.text)
else:
worklist_variable_value.setVariableValue(values[0]) #to be changed?
worklist_variable_value.setVariableValue(values[0]) #XXX(WORKFLOW): to be changed
worklist.setActboxUrl(qdef.actbox_url)
worklist.setActboxCategory(qdef.actbox_category)
......@@ -419,11 +419,11 @@ class WorkflowTool(BaseTool, OriginalWorkflowTool):
# configure guard
if qdef.guard:
worklist.guard = qdef.guard
worklist.setRoleList(qdef.guard.roles)
worklist.setPermissionList(qdef.guard.permissions)
worklist.setGroupList(qdef.guard.groups)
worklist.setGuardRoleList(qdef.guard.roles)
worklist.setGuardPermissionList(qdef.guard.permissions)
worklist.setGuardGroupList(qdef.guard.groups)
if qdef.guard.expr is not None:
worklist.setExpression(qdef.guard.expr.text)
worklist.setGuardExpression(qdef.guard.expr.text)
elif workflow_type_id == 'InteractionWorkflowDefinition':
dc_workflow_interaction_value_dict = dc_workflow.interactions
# create interactions (portal_type = Interaction)
......@@ -461,12 +461,12 @@ class WorkflowTool(BaseTool, OriginalWorkflowTool):
# configure guard
if tdef.guard:
interaction.guard = tdef.guard
interaction.setRoleList(tdef.guard.roles)
interaction.setPermissionList(tdef.guard.permissions)
interaction.setGroupList(tdef.guard.groups)
interaction.setGuardRoleList(tdef.guard.roles)
interaction.setGuardPermissionList(tdef.guard.permissions)
interaction.setGuardGroupList(tdef.guard.groups)
if tdef.guard.expr is not None:
# Here add expression text, convert to expression in getMatchVar.
interaction.setExpression(tdef.guard.expr.text)
interaction.setGuardExpression(tdef.guard.expr.text)
interaction.setPortalTypeFilter(tdef.portal_type_filter)
interaction.setPortalTypeGroupFilter(tdef.portal_type_group_filter)
if interaction.portal_type_filter == ():
......@@ -510,12 +510,12 @@ class WorkflowTool(BaseTool, OriginalWorkflowTool):
variable.setVariableExpression(variable_definition.default_expr.text)
if variable_definition.info_guard:
variable.info_guard = variable_definition.info_guard
variable.setRoleList(variable_definition.info_guard.roles)
variable.setPermissionList(variable_definition.info_guard.permissions)
variable.setGroupList(variable_definition.info_guard.groups)
variable.setGuardRoleList(variable_definition.info_guard.roles)
variable.setGuardPermissionList(variable_definition.info_guard.permissions)
variable.setGuardGroupList(variable_definition.info_guard.groups)
if variable_definition.info_guard.expr is not None:
# Here add expression text, convert to expression in getMatchVar.
variable.setExpression(tdef.info_guard.expr.text)
variable.setGuardExpression(tdef.info_guard.expr.text)
variable.setForCatalog(variable_definition.for_catalog)
variable.setStatusIncluded(variable_definition.for_status)
variable.setVariableValue(variable_definition.default_value)
......@@ -531,7 +531,6 @@ class WorkflowTool(BaseTool, OriginalWorkflowTool):
var_exprs = {}
else: var_exprs = origin_tdef.var_exprs
for key in var_exprs:
#import pdb; pdb.set_trace()
tr_var = transition.newContent(portal_type='Transition Variable', temp_object=is_temporary)
tr_var.setVariableExpression(var_exprs[key].text)
tr_var_path = getattr(workflow, 'variable_'+key).getPath()
......
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