--- a/src/pyams_sequence/reference.py Sat Jul 21 03:36:17 2018 +0200
+++ b/src/pyams_sequence/reference.py Sat Jul 21 03:36:59 2018 +0200
@@ -69,8 +69,10 @@
def get_last_version(content):
"""Check for last available version"""
- if handle_workflow and (IWorkflowVersion.providedBy(content) or IWorkflowManagedContent.providedBy(content)):
- content = IWorkflowVersions(content).get_last_versions()[0]
+ if handle_workflow:
+ versions = IWorkflowVersions(content, None)
+ if versions is not None:
+ content = versions.get_last_versions()[0]
if ISequentialIdInfo(content, None) is not None:
return content
else:
@@ -80,17 +82,15 @@
def get_visible_version(content):
"""Check for visible version"""
if handle_workflow:
- if IWorkflowVersion.providedBy(content) or IWorkflowManagedContent.providedBy(content):
+ versions = IWorkflowVersions(content, None)
+ if versions is not None:
workflow = IWorkflow(content)
- versions = IWorkflowVersions(content).get_versions(workflow.published_states, sort=True)
- if versions:
- return versions[-1]
+ visible_versions = versions.get_versions(workflow.published_states, sort=True)
+ if visible_versions:
+ return visible_versions[-1]
publication_info = IWorkflowPublicationInfo(content, None)
if publication_info is not None:
- if publication_info.is_visible():
- return content
- else:
- return None
+ return content if publication_info.is_visible() else None
return content