Commit 000dba76 authored by Julien Muchembled's avatar Julien Muchembled

Clean up some code using ActiveProcess.getResultList

parent e26beb3a
......@@ -8,14 +8,11 @@ if active_process is None:
else:
active_process = context.getPortalObject().restrictedTraverse(active_process)
result_list = []
constraint_message_list = []
if active_process is not None:
result_list = [x for x in active_process.getResultList()]
# High severity will be displayed first
result_list.sort(key=lambda x: -x.severity)
if active_process is None:
return []
for result in result_list:
constraint_message_list = []
for result in active_process.ActiveProcess_getResultList():
constraint_message_list.extend(result.getProperty('constraint_message_list') or [])
return constraint_message_list
if process is None:
return False
result_list = process.getResultList()
return result_list and bool(result_list[0].getProperty('severity')) or False
return bool(result_list and result_list[0].getProperty('severity'))
......@@ -3,35 +3,19 @@
or of the last process if nothing specified.
"""
def getLastActiveProcess(sub):
"""
This returns the last active process finished. So it will
not returns the current one
"""
limit = 1
active_process_list = context.getPortalObject().portal_catalog(
portal_type='Active Process', limit=limit,
if active_process is None:
# Get the last active process finished, not the current one.
active_process = context.getPortalObject().portal_catalog.getResultValue(
portal_type='Active Process',
sort_on=(('creation_date', 'DESC'),
# XXX Work around poor resolution of MySQL dates.
('CONVERT(`catalog`.`id`, UNSIGNED)', 'DESC')),
causality_uid=sub.getUid())
if len(active_process_list) < limit:
process = None
else:
process = active_process_list[-1].getObject()
return process
if active_process is None:
active_process = getLastActiveProcess(context)
else:
active_process = context.getPortalObject().restrictedTraverse(active_process)
result_list = []
if active_process is not None:
result_list = [x for x in active_process.getResultList()]
# High severity will be displayed first
result_list.sort(key=lambda x: -x.severity)
if active_process is None:
return []
return result_list
return active_process.ActiveProcess_getResultList()
......@@ -202,7 +202,6 @@ class TestUpgrader(ERP5TypeTestCase):
group_dict = DETAIL_PATTERN.match(detail).groupdict()
person = self.portal.restrictedTraverse(group_dict['relative_url'])
message_list = [m.message for m in person.checkConsistency()]
self.assertNotEqual(result_list, [])
self.assertEqual(len(result_list), 1)
return person, group_dict, detail, message_list
......
......@@ -8,11 +8,7 @@ if active_process is None:
else:
active_process = context.getPortalObject().restrictedTraverse(active_process)
result_list = []
if active_process is not None:
result_list = [x for x in active_process.getResultList()]
# High severity will be displayed first
result_list.sort(key=lambda x: -x.severity)
if active_process is None:
return []
return result_list
return active_process.ActiveProcess_getResultList()
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