Set publication effective date in publication form if missing
authorThierry Florac <thierry.florac@onf.fr>
Mon, 12 Nov 2018 12:16:25 +0100
changeset 1077 24ab1360b343
parent 1076 93f78438ff8c
child 1080 11d950caf9d2
Set publication effective date in publication form if missing
src/pyams_content/shared/common/zmi/workflow.py
--- a/src/pyams_content/shared/common/zmi/workflow.py	Mon Nov 12 12:07:52 2018 +0100
+++ b/src/pyams_content/shared/common/zmi/workflow.py	Mon Nov 12 12:16:25 2018 +0100
@@ -327,10 +327,12 @@
         super(PublicationForm, self).updateWidgets(prefix)
         pub_info = IWorkflowPublicationInfo(self.context)
         if 'publication_effective_date' in self.widgets:
-            self.widgets['publication_effective_date'].required = True
+            widget = self.widgets['publication_effective_date']
+            widget.required = True
             if pub_info.publication_effective_date:
-                self.widgets['publication_effective_date'].value = \
-                    tztime(pub_info.publication_effective_date).strftime('%d/%m/%y %H:%M')
+                widget.value = tztime(pub_info.publication_effective_date).strftime('%d/%m/%y %H:%M')
+            else:
+                widget.value = tztime(datetime.utcnow()).strftime('%d/%m/%y %H:%M')
         if ('push_end_date' in self.widgets) and pub_info.push_end_date:
             self.widgets['push_end_date'].value = \
                 tztime(pub_info.push_end_date).strftime('%d/%m/%y %H:%M')