src/pyams_content/shared/site/zmi/container.py
changeset 581 e8befd0dd932
parent 580 51bea2402bba
child 591 b694d5667d17
--- a/src/pyams_content/shared/site/zmi/container.py	Tue Jun 05 16:51:00 2018 +0200
+++ b/src/pyams_content/shared/site/zmi/container.py	Tue Jun 05 17:05:17 2018 +0200
@@ -9,7 +9,6 @@
 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
 # FOR A PARTICULAR PURPOSE.
 #
-from z3c.table.column import GetAttrColumn
 
 __docformat__ = 'restructuredtext'
 
@@ -17,6 +16,8 @@
 # import standard library
 import json
 
+from datetime import datetime
+
 # import interfaces
 from pyams_content.interfaces import MANAGE_SITE_PERMISSION, MANAGE_CONTENT_PERMISSION
 from pyams_content.shared.common.interfaces import ISharedContent
@@ -55,6 +56,7 @@
 from pyams_utils.adapter import adapter_config, ContextRequestViewAdapter, ContextRequestAdapter
 from pyams_utils.fanstatic import get_resource_path
 from pyams_utils.registry import get_utility
+from pyams_utils.timezone import tztime
 from pyams_utils.traversing import get_parent
 from pyams_utils.url import absolute_url
 from pyams_viewlet.manager import viewletmanager_config
@@ -65,6 +67,7 @@
 from pyramid.location import lineage
 from pyramid.view import view_config
 from z3c.form import field
+from z3c.table.column import GetAttrColumn
 from zope.interface import implementer
 from zope.lifecycleevent import ObjectMovedEvent
 
@@ -131,6 +134,13 @@
     ajax_handler = 'workflow-publication.json'
     edit_permission = MANAGE_SITE_PERMISSION
 
+    def updateWidgets(self, prefix=None):
+        super(SiteContainerWorkflowPublicationEditForm, self).updateWidgets(prefix)
+        if 'publication_effective_date' in self.widgets:
+            widget = self.widgets['publication_effective_date']
+            if not widget.value:
+                widget.value = tztime(datetime.utcnow()).strftime('%d/%m/%y %H:%M')
+
 
 @view_config(name='workflow-publication.json', context=ISiteContainer, request_type=IPyAMSLayer,
              permission=MANAGE_SITE_PERMISSION, renderer='json', xhr=True)