Commit f88a2f32 authored by Vincent Pelletier's avatar Vincent Pelletier

ERP5Type.Base: Trivial cleanups for getCreationDate.

- do not use getToolByName.
- do not put two statements on the same line
- merge nested "if" statements around a single code block
parent acf2e5ed
...@@ -3088,17 +3088,17 @@ class Base( CopyContainer, ...@@ -3088,17 +3088,17 @@ class Base( CopyContainer,
Returns the creation date of the document based on workflow information Returns the creation date of the document based on workflow information
""" """
# Check if edit_workflow defined # Check if edit_workflow defined
portal_workflow = getToolByName(self.getPortalObject(), 'portal_workflow') portal_workflow = self.getPortalObject().portal_workflow
wf = portal_workflow.getWorkflowById('edit_workflow') wf = portal_workflow.getWorkflowById('edit_workflow')
wf_list = list(portal_workflow.getWorkflowsFor(self)) wf_list = portal_workflow.getWorkflowsFor(self)
if wf is not None: wf_list = [wf] + wf_list if wf is not None:
wf_list = [wf] + wf_list
for wf in wf_list: for wf in wf_list:
try: try:
history = wf.getInfoFor(self, 'history', None) history = wf.getInfoFor(self, 'history', None)
except KeyError: except KeyError:
history = None history = None
if history is not None: if history is not None and len(history):
if len(history):
# Then get the first line of edit_workflow # Then get the first line of edit_workflow
return history[0].get('time', None) return history[0].get('time', None)
if getattr(aq_base(self), 'CreationDate', None) is not None: if getattr(aq_base(self), 'CreationDate', None) is not None:
......
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