--- a/src/pyams_content_es/component/workflow.py Fri Nov 09 12:13:05 2018 +0100
+++ b/src/pyams_content_es/component/workflow.py Wed Nov 14 17:45:43 2018 +0100
@@ -12,32 +12,38 @@
__docformat__ = 'restructuredtext'
-
-# import standard library
-
-# import interfaces
-from pyams_content_es.interfaces import IDocumentIndexInfo
-from pyams_workflow.interfaces import IWorkflowState, IWorkflowPublicationSupport, IWorkflowInfo, \
- IWorkflowPublicationInfo
from zope.dublincore.interfaces import IZopeDublinCore
-# import packages
+from pyams_content_es.interfaces import IDocumentIndexInfo
from pyams_utils.adapter import adapter_config
+from pyams_workflow.interfaces import IWorkflowInfo, IWorkflowPublicationInfo, IWorkflowPublicationSupport, \
+ IWorkflowState
@adapter_config(name='workflow', context=IWorkflowPublicationSupport, provides=IDocumentIndexInfo)
def workflow_managed_content_index_info(content):
"""Workflow managed content index info"""
dc_info = IZopeDublinCore(content)
- workflow_state = IWorkflowState(content)
- workflow_info = IWorkflowPublicationInfo(content)
- return {'workflow': {'name': IWorkflowInfo(content).name,
- 'status': workflow_state.state,
- 'date': workflow_state.state_date,
- 'created_date': dc_info.created,
- 'modified_date': dc_info.modified,
- 'publication_date': workflow_info.publication_date,
- 'effective_date': workflow_info.publication_effective_date,
- 'push_end_date': workflow_info.push_end_date,
- 'expiration_date': workflow_info.publication_expiration_date,
- 'first_publication_date': workflow_info.first_publication_date}}
+ result = {
+ 'created_date': dc_info.created,
+ 'modified_date': dc_info.modified
+ }
+ workflow_info = IWorkflowInfo(content, None)
+ if workflow_info is not None:
+ result.update({'name': workflow_info.name})
+ workflow_pub_info = IWorkflowPublicationInfo(content, None)
+ if workflow_pub_info is not None:
+ result.update({
+ 'publication_date': workflow_pub_info.publication_date,
+ 'effective_date': workflow_pub_info.publication_effective_date,
+ 'push_end_date': workflow_pub_info.push_end_date,
+ 'expiration_date': workflow_pub_info.publication_expiration_date,
+ 'first_publication_date': workflow_pub_info.first_publication_date
+ })
+ workflow_state = IWorkflowState(content, None)
+ if workflow_state is not None:
+ result.update({
+ 'status': workflow_state.state,
+ 'date': workflow_state.state_date,
+ })
+ return {'workflow': result}