Added 'complete' argument to IWorkflowPublicationInfo.reset method to be able to keep previous push and publication end dates
authorThierry Florac <thierry.florac@onf.fr>
Fri, 08 Dec 2017 11:48:16 +0100
changeset 49 8ffebf1c77c2
parent 48 caa4dfcc51ee
child 50 98f60c2f4332
Added 'complete' argument to IWorkflowPublicationInfo.reset method to be able to keep previous push and publication end dates
src/pyams_workflow/content.py
src/pyams_workflow/interfaces/__init__.py
--- a/src/pyams_workflow/content.py	Mon Dec 04 15:26:42 2017 +0100
+++ b/src/pyams_workflow/content.py	Fri Dec 08 11:48:16 2017 +0100
@@ -147,12 +147,13 @@
             del IZopeDublinCore(self.__parent__)._mapping['Date.Expires']
         self._publication_expiration_date = value
 
-    def reset(self):
+    def reset(self, complete=True):
         self._publication_date = None
         self._first_publication_date = None
         self._publication_effective_date = None
-        self._publication_expiration_date = None
-        self.push_end_date = None
+        if complete:
+            self._publication_expiration_date = None
+            self.push_end_date = None
 
     def is_published(self, check_parent=True):
         # check is parent is published
@@ -228,4 +229,4 @@
 @subscriber(IObjectClonedEvent, context_selector=IWorkflowPublicationSupport)
 def handle_cloned_publication_support(event):
     """Reset publication info when an object is cloned"""
-    IWorkflowPublicationInfo(event.object).reset()
+    IWorkflowPublicationInfo(event.object).reset(complete=False)
--- a/src/pyams_workflow/interfaces/__init__.py	Mon Dec 04 15:26:42 2017 +0100
+++ b/src/pyams_workflow/interfaces/__init__.py	Fri Dec 08 11:48:16 2017 +0100
@@ -464,8 +464,12 @@
 
     visible_publication_date = Attribute("Visible publication date")
 
-    def reset(self):
-        """Reset all publication info (used by clone features)"""
+    def reset(self, complete=True):
+        """Reset all publication info (used by clone features)
+
+        If 'complete' argument is True, all date fields are reset; otherwise, push and publication end dates are
+        preserved in new versions.
+        """
 
     def is_published(self, check_parent=True):
         """Is the content published?"""