Commit 7f2b822b authored by Vincent Pelletier's avatar Vincent Pelletier

Allow getSecurityUidListAndRoleColumnDict to be None in groupWorklistListByCondition (part 1 of 2)

 - update prototype
 - add test
 - add methods to factorize code
 - add method calls in new code branch
 - indent existing code branch (to make changes in this branch obvious in next commit)


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@17364 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent e00cc9dd
...@@ -95,8 +95,38 @@ class ExclusionTuple(tuple): ...@@ -95,8 +95,38 @@ class ExclusionTuple(tuple):
""" """
pass pass
def getValidCriterionDict(worklist_match_dict, acceptable_key_dict):
valid_criterion_dict = {}
metadata = None
for criterion_id, criterion_value in worklist_match_dict.iteritems():
if criterion_id in acceptable_key_dict:
if isinstance(criterion_value, tuple):
criterion_value = list(criterion_value)
assert criterion_id not in valid_criterion_dict
valid_criterion_dict[criterion_id] = criterion_value
elif criterion_id == WORKLIST_METADATA_KEY:
metadata = criterion_value
elif criterion_id == SECURITY_PARAMETER_ID:
pass
else:
LOG('WorkflowTool_listActions', WARNING, 'Worklist %s of ' \
'workflow %s filters on variable %s which is not available ' \
'in catalog. Its value will not be checked.' % \
(worklist_id, workflow_id, criterion_id))
return valid_criterion_dict, metadata
def updateWorklistSetDict(worklist_set_dict, workflow_worklist_key, valid_criterion_dict):
worklist_set_dict_key = valid_criterion_dict.keys()
if len(worklist_set_dict_key):
worklist_set_dict_key.sort()
worklist_set_dict_key = tuple(worklist_set_dict_key)
if worklist_set_dict_key not in worklist_set_dict:
worklist_set_dict[worklist_set_dict_key] = {}
worklist_set_dict[worklist_set_dict_key]\
[workflow_worklist_key] = valid_criterion_dict
def groupWorklistListByCondition(worklist_dict, acceptable_key_dict, def groupWorklistListByCondition(worklist_dict, acceptable_key_dict,
getSecurityUidListAndRoleColumnDict): getSecurityUidListAndRoleColumnDict=None):
""" """
Get a list of dict of WorklistVariableMatchDict grouped by compatible Get a list of dict of WorklistVariableMatchDict grouped by compatible
conditions. conditions.
...@@ -133,6 +163,17 @@ def groupWorklistListByCondition(worklist_dict, acceptable_key_dict, ...@@ -133,6 +163,17 @@ def groupWorklistListByCondition(worklist_dict, acceptable_key_dict,
for workflow_id, worklist in worklist_dict.iteritems(): for workflow_id, worklist in worklist_dict.iteritems():
for worklist_id, worklist_match_dict in worklist.iteritems(): for worklist_id, worklist_match_dict in worklist.iteritems():
workflow_worklist_key = '/'.join((workflow_id, worklist_id)) workflow_worklist_key = '/'.join((workflow_id, worklist_id))
if getSecurityUidListAndRoleColumnDict is None:
valid_criterion_dict, metadata = getValidCriterionDict(
worklist_match_dict=worklist_match_dict,
acceptable_key_dict=acceptable_key_dict)
if metadata is not None:
metadata_dict[workflow_worklist_key] = metadata
updateWorklistSetDict(
worklist_set_dict=worklist_set_dict,
workflow_worklist_key=workflow_worklist_key,
valid_criterion_dict=valid_criterion_dict)
else:
security_parameter = worklist_match_dict.get(SECURITY_PARAMETER_ID, []) security_parameter = worklist_match_dict.get(SECURITY_PARAMETER_ID, [])
security_kw = {} security_kw = {}
if len(security_parameter): if len(security_parameter):
......
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