Commit f1b00bd2 authored by Jérome Perrin's avatar Jérome Perrin

support invert mode selection and checked uids.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@17979 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 510b9fdb
...@@ -42,7 +42,7 @@ def getDocumentGroupByWorkflowStateList(self, **kw): ...@@ -42,7 +42,7 @@ def getDocumentGroupByWorkflowStateList(self, **kw):
def get_url(*args, **kw): def get_url(*args, **kw):
return '%s/view?reset:int=1&%s=%s&portal_type=%s' % ( return '%s/view?reset:int=1&%s=%s&portal_type=%s' % (
self.absolute_url(), state_var, doc.getProperty(state_var), self.absolute_url(), state_var, doc.getProperty(state_var),
doc.getPortalType()) doc.getPortalTypeName())
return get_url return get_url
request = self.REQUEST request = self.REQUEST
...@@ -58,7 +58,6 @@ def getDocumentGroupByWorkflowStateList(self, **kw): ...@@ -58,7 +58,6 @@ def getDocumentGroupByWorkflowStateList(self, **kw):
# If there are checked uids, only use checked uids. # If there are checked uids, only use checked uids.
selection_uid_list = selection_tool.getSelectionCheckedUidsFor(selection_name) selection_uid_list = selection_tool.getSelectionCheckedUidsFor(selection_name)
# TODO invert mode: calculate in python
document_list = [] document_list = []
...@@ -89,22 +88,49 @@ def getDocumentGroupByWorkflowStateList(self, **kw): ...@@ -89,22 +88,49 @@ def getDocumentGroupByWorkflowStateList(self, **kw):
count=brain.count, count=brain.count,
workflow_id=workflow.getId(), workflow_id=workflow.getId(),
portal_type=doc.getPortalType(), portal_type=doc.getPortalTypeName(),
state_var=state_var, state_var=state_var,
workflow_state=doc.getProperty(state_var), workflow_state=doc.getProperty(state_var),
)) ))
else: else:
getObject = portal.portal_catalog.getObject getObject = portal.portal_catalog.getObject
selected_document_list = [getObject(uid) for uid in selection_uid_list]
marker = []
# this will be a dictionnary with (portal_type, workflow_id, workflow_state)
# as keys, and (count, a random document) as values
workflow_state_dict = dict() workflow_state_dict = dict()
for document in [getObject(uid) for uid in selection_uid_list]:
state = document.getProperty(workflow_state)
ptype = document.getPortalTypeName()
workflow_state_dict[(ptype, state)] = \
workflow_state_dict.get((ptype, state), 0) + 1
document_list = [Object(uid='new_', for document in selected_document_list:
translated_portal_type='TODO: count in python')] for state_var in possible_state_list:
for workflow in wf_tool.getWorkflowsFor(document):
if state_var == workflow.variables.getStateVar():
key = (document.getPortalTypeName(), workflow,
document.getProperty(state_var))
document_count = workflow_state_dict.get(key, [None, 0])[1]
workflow_state_dict[key] = document, document_count + 1
counter = 0
for (ptype, workflow, state), (doc, document_count) in\
workflow_state_dict.items():
counter += 1
state_var = workflow.variables.getStateVar()
translated_workflow_state_title = doc.getProperty(
'translated_%s_title' % state_var)
document_list.append(doc.asContext(
uid='new_%s' % counter,
getListItemUrl=UrlGetter(doc, state_var),
workflow_title=N_(workflow.title_or_id()),
translated_workflow_state_title=
translated_workflow_state_title,
count=document_count,
workflow_id=workflow.getId(),
portal_type=doc.getPortalTypeName(),
state_var=state_var,
workflow_state=doc.getProperty(state_var),
))
return document_list return document_list
...@@ -122,11 +148,13 @@ def getWorkflowActionDocumentList(self, **kw): ...@@ -122,11 +148,13 @@ def getWorkflowActionDocumentList(self, **kw):
searchResults = portal.portal_catalog.searchResults searchResults = portal.portal_catalog.searchResults
wtool = portal.portal_workflow wtool = portal.portal_workflow
stool = portal.portal_selections stool = portal.portal_selections
original_selection_params = \ original_selection_params = stool.getSelectionParamsFor(selection_name)
portal.portal_selections.getSelectionParamsFor(selection_name)
original_selection_params.setdefault('sort_on', kw.get('sort_on')) original_selection_params.setdefault('sort_on', kw.get('sort_on'))
# TODO: invert mode selection_uid_list = stool.getSelectionCheckedUidsFor(selection_name)
if selection_uid_list:
original_selection_params['uid'] = selection_uid_list
for listbox_selection in listbox: for listbox_selection in listbox:
if listbox_selection.get('workflow_action'): if listbox_selection.get('workflow_action'):
......
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