Commit fdfe9a5a authored by Vincent Pelletier's avatar Vincent Pelletier

Add an src__ parameter to WorkflowTool_listActions patch to get SQL query list...

Add an src__ parameter to WorkflowTool_listActions patch to get SQL query list instead of action list.
Remove unneeded commented-out LOG (now, source is available).
Do not use intermediate parameter dict search_result_kw now that only one call with those parameters remains.
Note: SQL used to refresh worklist cache table is not inclued in this change.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@18880 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 5b12434d
...@@ -446,7 +446,7 @@ def generateActionList(worklist_metadata, worklist_result, portal_url): ...@@ -446,7 +446,7 @@ def generateActionList(worklist_metadata, worklist_result, portal_url):
'category': metadata['action_box_category']}) 'category': metadata['action_box_category']})
return action_list return action_list
def WorkflowTool_listActions(self, info=None, object=None): def WorkflowTool_listActions(self, info=None, object=None, src__=False):
""" """
Returns a list of actions to be displayed to the user. Returns a list of actions to be displayed to the user.
...@@ -512,6 +512,8 @@ def WorkflowTool_listActions(self, info=None, object=None): ...@@ -512,6 +512,8 @@ def WorkflowTool_listActions(self, info=None, object=None):
acceptable_key_dict=acceptable_key_dict, acceptable_key_dict=acceptable_key_dict,
getSecurityUidListAndRoleColumnDict=\ getSecurityUidListAndRoleColumnDict=\
getSecurityUidListAndRoleColumnDict) getSecurityUidListAndRoleColumnDict)
if src__:
action_list = []
for grouped_worklist_dict in worklist_list_grouped_by_condition: for grouped_worklist_dict in worklist_list_grouped_by_condition:
# Generate the query for this worklist_list # Generate the query for this worklist_list
(total_criterion_id_list, query) = \ (total_criterion_id_list, query) = \
...@@ -519,31 +521,36 @@ def WorkflowTool_listActions(self, info=None, object=None): ...@@ -519,31 +521,36 @@ def WorkflowTool_listActions(self, info=None, object=None):
group_by_expression = ', '.join(total_criterion_id_list) group_by_expression = ', '.join(total_criterion_id_list)
assert COUNT_COLUMN_TITLE not in total_criterion_id_list assert COUNT_COLUMN_TITLE not in total_criterion_id_list
select_expression = select_expression_prefix + group_by_expression select_expression = select_expression_prefix + group_by_expression
search_result_kw = {'select_expression': select_expression, catalog_brain_result = search_result(select_expression=select_expression,
'group_by_expression': group_by_expression, group_by_expression=group_by_expression,
'query': query} query=query,
#LOG('WorklistGeneration', WARNING, 'Using query: %s' % \ src__=src__)
# (search_result(src__=1, **search_result_kw), )) if src__:
catalog_brain_result = search_result(**search_result_kw) action_list.append(catalog_brain_result)
grouped_worklist_result = sumCatalogResultByWorklist( else:
grouped_worklist_dict=grouped_worklist_dict, grouped_worklist_result = sumCatalogResultByWorklist(
catalog_result=catalog_brain_result) grouped_worklist_dict=grouped_worklist_dict,
for key, value in grouped_worklist_result.iteritems(): catalog_result=catalog_brain_result)
worklist_result_dict[key] = value + worklist_result_dict.get(key, 0) for key, value in grouped_worklist_result.iteritems():
action_list = generateActionList(worklist_metadata=worklist_metadata, worklist_result_dict[key] = value + worklist_result_dict.get(key, 0)
worklist_result=worklist_result_dict, if not src__:
portal_url=portal_url) action_list = generateActionList(worklist_metadata=worklist_metadata,
def get_action_ident(action): worklist_result=worklist_result_dict,
return '/'.join((action['workflow_id'], action['worklist_id'])) portal_url=portal_url)
def action_cmp(action_a, action_b): def get_action_ident(action):
return cmp(get_action_ident(action_a), get_action_ident(action_b)) return '/'.join((action['workflow_id'], action['worklist_id']))
action_list.sort(action_cmp) def action_cmp(action_a, action_b):
return cmp(get_action_ident(action_a), get_action_ident(action_b))
action_list.sort(action_cmp)
return action_list return action_list
user = str(_getAuthenticatedUser(self)) user = str(_getAuthenticatedUser(self))
_getWorklistActionList = CachingMethod(_getWorklistActionList, if src__:
id=('_getWorklistActionList', user, portal_url), actions = _getWorklistActionList()
cache_factory = 'erp5_ui_short') else:
actions.extend(_getWorklistActionList()) _getWorklistActionList = CachingMethod(_getWorklistActionList,
id=('_getWorklistActionList', user, portal_url),
cache_factory = 'erp5_ui_short')
actions.extend(_getWorklistActionList())
return actions return actions
WorkflowTool.listActions = WorkflowTool_listActions WorkflowTool.listActions = WorkflowTool_listActions
......
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