--- a/src/pyams_content/shared/common/zmi/summary.py Mon Sep 11 14:50:14 2017 +0200
+++ b/src/pyams_content/shared/common/zmi/summary.py Mon Sep 11 14:50:56 2017 +0200
@@ -14,6 +14,7 @@
# import standard library
+from datetime import datetime
# import interfaces
from pyams_content.shared.common.interfaces import IWfSharedContent, IWfSharedContentRoles, ISharedTool
@@ -169,12 +170,26 @@
legend = _("Content history")
- fields = field.Fields(IWfSharedContent).select('first_owner') + \
- field.Fields(IWorkflowPublicationInfo).select('first_publication_date')
+ fields = field.Fields(IWorkflowPublicationInfo).select('first_publication_date') + \
+ field.Fields(IWfSharedContent).select('first_owner')
weight = 40
def updateWidgets(self, prefix=None):
super(SharedContentWorkflowHistorySummary, self).updateWidgets(prefix)
- info = IWorkflowPublicationInfo(self.context)
- self.widgets['first_publication_date'].value = format_datetime(tztime(info.first_publication_date))
+ workflow = IWorkflow(self.context)
+ state = IWorkflowState(self.context)
+ pub_date = tztime(state.get_first_state_date(workflow.published_states))
+ if pub_date is None:
+ value = '--'
+ else:
+ now = tztime(datetime.utcnow())
+ pub_info = IWorkflowPublicationInfo(self.context)
+ if (pub_info.publication_effective_date is None) or (pub_date >= pub_info.publication_effective_date):
+ value = format_datetime(tztime(pub_date))
+ else:
+ if pub_info.publication_effective_date < now:
+ value = '--'
+ else:
+ value = format_datetime(tztime(pub_info.publication_effective_date))
+ self.widgets['first_publication_date'].value = value