Updated workflow publication form
authorThierry Florac <tflorac@ulthar.net>
Sat, 09 Jun 2018 00:07:00 +0200
changeset 600 33811e279b1d
parent 599 7f97d8cae72e
child 601 5c16e7815b69
Updated workflow publication form
src/pyams_content/shared/common/zmi/workflow.py
src/pyams_content/shared/site/zmi/container.py
--- a/src/pyams_content/shared/common/zmi/workflow.py	Fri Jun 08 18:05:11 2018 +0200
+++ b/src/pyams_content/shared/common/zmi/workflow.py	Sat Jun 09 00:07:00 2018 +0200
@@ -9,12 +9,6 @@
 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
 # FOR A PARTICULAR PURPOSE.
 #
-from z3c.form.browser.radio import RadioWidget
-from z3c.form.widget import FieldWidget
-
-from pyams_form.group import NamedWidgetsGroup
-from pyams_form.interfaces import IFormLayer
-from pyams_form.widget import widgettemplate_config
 
 __docformat__ = 'restructuredtext'
 
@@ -26,6 +20,7 @@
 from pyams_content.interfaces import PUBLISH_CONTENT_PERMISSION, CREATE_CONTENT_PERMISSION, MANAGE_CONTENT_PERMISSION
 from pyams_content.shared.common.interfaces import IWfSharedContent, IBaseSharedTool, ISharedContent, \
     IContributorRestrictions, IManagerRestrictions
+from pyams_form.interfaces import IFormLayer
 from pyams_form.interfaces.form import IWidgetsPrefixViewletsManager, IFormSuffixViewletsManager, IInnerSubForm
 from pyams_security.interfaces import ISecurityManager
 from pyams_skin.layer import IPyAMSLayer
@@ -38,6 +33,7 @@
 from pyams_content.workflow import DRAFT, DELETED
 from pyams_form.form import AJAXAddForm, ajax_config
 from pyams_form.schema import CloseButton
+from pyams_form.widget import widgettemplate_config
 from pyams_pagelet.pagelet import pagelet_config
 from pyams_template.template import template_config
 from pyams_utils.adapter import adapter_config
@@ -51,8 +47,9 @@
 from pyams_workflow.zmi.transition import WorkflowContentTransitionForm, WorkflowContentTransitionAJAXForm
 from pyams_zmi.form import InnerAdminAddForm
 from pyramid.events import subscriber
-from pyramid.view import view_config
 from z3c.form import field, button
+from z3c.form.browser.radio import RadioWidget
+from z3c.form.widget import FieldWidget
 from zope.interface import Interface, Invalid
 from zope.schema import Bool
 
--- a/src/pyams_content/shared/site/zmi/container.py	Fri Jun 08 18:05:11 2018 +0200
+++ b/src/pyams_content/shared/site/zmi/container.py	Sat Jun 09 00:07:00 2018 +0200
@@ -137,9 +137,9 @@
     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')
+            pub_info = IWorkflowPublicationInfo(self.context)
+            if pub_info.publication_effective_date is None:
+                self.widgets['publication_effective_date'].value = tztime(datetime.utcnow()).strftime('%d/%m/%y %H:%M')
 
     def get_ajax_output(self, changes):
         output = super(self.__class__, self).get_ajax_output(changes)