Commit af602342 authored by Jean-Paul Smets's avatar Jean-Paul Smets

With this patch, it is no longer necessary to define a portal type in...

With this patch, it is no longer necessary to define a portal type in worklists. Also, worklists which are not used will not be displayed. This solves an old issue related to the overloading of workflows in customer projects.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@13337 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 2cb67f14
...@@ -66,6 +66,23 @@ def DCWorkflowDefinition_listGlobalActions(self, info): ...@@ -66,6 +66,23 @@ def DCWorkflowDefinition_listGlobalActions(self, info):
if not self.worklists: if not self.worklists:
return None # Optimization return None # Optimization
# Prevent including this worklist if
# the workflow is not used by any portal type
def getPortalTypeListForWorkflow(workflow_id):
workflow_tool = getToolByName(self, 'portal_workflow')
result = []
for type_info in workflow_tool._listTypeInfo():
portal_type = type_info.id
if workflow_id in workflow_tool.getChainFor(portal_type):
result.append(portal_type)
return result
_getPortalTypeListForWorkflow = CachingMethod(getPortalTypeListForWorkflow,
id='_getPortalTypeListForWorkflow', cache_factory = 'erp5_ui_long')
portal_type_list = _getPortalTypeListForWorkflow(self.id)
if not portal_type_list:
return None
def _listGlobalActions(user=None, id=None, portal_path=None): def _listGlobalActions(user=None, id=None, portal_path=None):
sm = getSecurityManager() sm = getSecurityManager()
portal = self._getPortalRoot() portal = self._getPortalRoot()
...@@ -90,6 +107,11 @@ def DCWorkflowDefinition_listGlobalActions(self, info): ...@@ -90,6 +107,11 @@ def DCWorkflowDefinition_listGlobalActions(self, info):
v = qdef.getVarMatch(k) v = qdef.getVarMatch(k)
v_fmt = map(lambda x, info=info: x%info, v) v_fmt = map(lambda x, info=info: x%info, v)
dict[k] = v_fmt dict[k] = v_fmt
# Patch to automatically filter workflists per portal type
# so that the same state can be used for different
# worklists and they are not merged
if not dict.has_key('portal_type'):
dict['portal_type'] = portal_type_list
# Patch for ERP5 by JP Smets in order # Patch for ERP5 by JP Smets in order
# to implement worklists and search of local roles # to implement worklists and search of local roles
if not (guard is None or guard.check(sm, self, portal)): if not (guard is None or guard.check(sm, self, portal)):
...@@ -103,6 +125,10 @@ def DCWorkflowDefinition_listGlobalActions(self, info): ...@@ -103,6 +125,10 @@ def DCWorkflowDefinition_listGlobalActions(self, info):
fmt_data = TemplateDict() fmt_data = TemplateDict()
fmt_data._push(info) fmt_data._push(info)
fmt_data._push({'count': searchres_len}) fmt_data._push({'count': searchres_len})
# Patch for ERP5 by JP Smets in order to
# filter per portal type more easily (ie. without
# hardcoding it all)
fmt_data._push({'portal_type': ' OR '.join(portal_type_list)})
# Patch for ERP5 by JP Smets in order # Patch for ERP5 by JP Smets in order
# to implement worklists and search of local roles # to implement worklists and search of local roles
if dict.has_key('local_roles'): if dict.has_key('local_roles'):
......
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