Commit 63f1674c authored by wenjie.zheng's avatar wenjie.zheng

Workflow.py: load ERP5 worklist.

parent a19e00b5
...@@ -362,9 +362,10 @@ class Workflow(XMLObject): ...@@ -362,9 +362,10 @@ class Workflow(XMLObject):
(worklist id as key) and which value is a dict composed of (worklist id as key) and which value is a dict composed of
variable matches. variable matches.
""" """
if not self.objectValues(portal_type='Worklist'): if not self.contentValues(portal_type='Worklist'):
return None return None
### zwj: for DC workflow
portal = self.getPortalObject() portal = self.getPortalObject()
def getPortalTypeListForWorkflow(workflow_id): def getPortalTypeListForWorkflow(workflow_id):
workflow_tool = portal.portal_workflow workflow_tool = portal.portal_workflow
...@@ -384,12 +385,14 @@ class Workflow(XMLObject): ...@@ -384,12 +385,14 @@ class Workflow(XMLObject):
variable_match_dict = {} variable_match_dict = {}
security_manager = getSecurityManager() security_manager = getSecurityManager()
workflow_id = self.id workflow_id = self.id
workflow_title = self.title workflow_title = self.getTitle()
for worklist_id, worklist_definition in self.worklists.items(): for worklist_definition in self.objectValues(portal_type='Worklist'):
worklist_id = worklist_definition.getId()
action_box_name = worklist_definition.actbox_name action_box_name = worklist_definition.actbox_name
guard = worklist_definition.guard guard = worklist_definition.getGuard()
if action_box_name: if action_box_name:
variable_match = {} variable_match = {}
for key in worklist_definition.getVarMatchKeys(): for key in worklist_definition.getVarMatchKeys():
var = worklist_definition.getVarMatch(key) var = worklist_definition.getVarMatch(key)
if isinstance(var, Expression): if isinstance(var, Expression):
...@@ -400,6 +403,7 @@ class Workflow(XMLObject): ...@@ -400,6 +403,7 @@ class Workflow(XMLObject):
else: else:
evaluated_value = [x % info for x in var] evaluated_value = [x % info for x in var]
variable_match[key] = evaluated_value variable_match[key] = evaluated_value
if 'portal_type' in variable_match and len(variable_match['portal_type']): if 'portal_type' in variable_match and len(variable_match['portal_type']):
portal_type_intersection = set(variable_match['portal_type'])\ portal_type_intersection = set(variable_match['portal_type'])\
.intersection(portal_type_list) .intersection(portal_type_list)
...@@ -425,18 +429,20 @@ class Workflow(XMLObject): ...@@ -425,18 +429,20 @@ class Workflow(XMLObject):
variable_match.setdefault(SECURITY_PARAMETER_ID, ()) variable_match.setdefault(SECURITY_PARAMETER_ID, ())
format_data._push(dict((k, ('&%s:list=' % k).join(v)) for\ format_data._push(dict((k, ('&%s:list=' % k).join(v)) for\
k, v in variable_match.iteritems())) k, v in variable_match.iteritems()))
variable_match[WORKLIST_METADATA_KEY] = {'format_data': format_data, variable_match[WORKLIST_METADATA_KEY] = {
'worklist_title': action_box_name, 'name': worklist_definition.actbox_name % fmt_data,
'worklist_id': worklist_id, 'url': '%s/%s' % (str(portal_url), str(worklist_definition.actbox_url) % fmt_data),
'workflow_title': workflow_title, 'worklist_id': worklist_id,
'workflow_id': workflow_id, 'workflow_title': self.getTitle(),
'action_box_url': worklist_definition.actbox_url, 'workflow_id': self.getId(),
'action_box_category': worklist_definition.actbox_category} 'permissions': (), # Predetermined.
'category': worklist_definition.actbox_category}
variable_match_dict[worklist_id] = variable_match variable_match_dict[worklist_id] = variable_match
if len(variable_match_dict) == 0: if len(variable_match_dict) == 0:
return None return None
return variable_match_dict return variable_match_dict
# ============================================================================
security.declarePrivate('getInfoFor') security.declarePrivate('getInfoFor')
def getInfoFor(self, ob, name, default): def getInfoFor(self, ob, name, default):
......
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