Commit 0dd3840f authored by Klaus Wölfel's avatar Klaus Wölfel

Fix a broken case of Worklist calculation when using security_uid columns

parent f2a06123
......@@ -39,6 +39,7 @@ from Acquisition import aq_base
from Products.ERP5Type.Globals import PersistentMapping
from MySQLdb import ProgrammingError, OperationalError
from DateTime import DateTime
from collections import defaultdict
security = ClassSecurityInfo()
WorkflowTool.security = security
......@@ -376,21 +377,17 @@ def sumCatalogResultByWorklist(grouped_worklist_dict, catalog_result):
It is better to avoid reading multiple times the catalog result from
flexibility point of view: if it must ever be changed into a cursor, this
code will keep working nicely without needing to rewind the cursor.
This code assumes that all worklists have the same set of criterion ids,
and that when a criterion id is associated with an ExclusionList it is
also true for all worklists.
"""
worklist_result_dict = {}
if len(catalog_result) > 0:
# Transtype all worklist definitions where needed
criterion_id_list = []
criterion_id_list_by_worklist_dict = defaultdict(list)
class_dict = {name: _sql_cast_dict.get(x['type'], _sql_cast_fallback)
for name, x in catalog_result.data_dictionary().iteritems()}
for criterion_dict in grouped_worklist_dict.itervalues():
for worklist_id, criterion_dict in grouped_worklist_dict.iteritems():
for criterion_id, criterion_value_list in criterion_dict.iteritems():
if type(criterion_value_list) is not ExclusionList:
criterion_id_list.append(criterion_id)
criterion_id_list_by_worklist_dict[worklist_id].append(criterion_id)
expected_class = class_dict[criterion_id]
if type(criterion_value_list[0]) is not expected_class:
criterion_dict[criterion_id] = ImmutableSet([expected_class(x) for x in criterion_value_list])
......@@ -401,7 +398,7 @@ def sumCatalogResultByWorklist(grouped_worklist_dict, catalog_result):
result_count = int(result_line[COUNT_COLUMN_TITLE])
for worklist_id, criterion_dict in grouped_worklist_dict.iteritems():
is_candidate = True
for criterion_id in criterion_id_list:
for criterion_id in criterion_id_list_by_worklist_dict[worklist_id]:
criterion_value_set = criterion_dict[criterion_id]
if result_line[criterion_id] not in criterion_value_set:
is_candidate = False
......
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