Added 'principal' parameter in several workflow interfaces
authorThierry Florac <thierry.florac@onf.fr>
Mon, 11 Sep 2017 14:25:27 +0200
changeset 35 c879fc48d6b1
parent 34 350607d4de7e
child 36 a84e933260c6
Added 'principal' parameter in several workflow interfaces
src/pyams_workflow/interfaces/__init__.py
--- a/src/pyams_workflow/interfaces/__init__.py	Wed Jul 12 17:46:40 2017 +0200
+++ b/src/pyams_workflow/interfaces/__init__.py	Mon Sep 11 14:25:27 2017 +0200
@@ -81,6 +81,8 @@
 
     wokflow = Attribute("Workflow utility")
 
+    principal = Attribute("Event principal")
+
     source = Attribute('Original state or None if initial state')
 
     destination = Attribute('New state')
@@ -94,9 +96,10 @@
 class WorkflowTransitionEvent(ObjectEvent):
     """Workflow transition event"""
 
-    def __init__(self, object, workflow, source, destination, transition, comment):
+    def __init__(self, object, workflow, principal, source, destination, transition, comment):
         super(WorkflowTransitionEvent, self).__init__(object)
         self.workflow = workflow
+        self.principal = principal
         self.source = source
         self.destination = destination
         self.transition = transition
@@ -113,8 +116,9 @@
 class WorkflowVersionTransitionEvent(WorkflowTransitionEvent):
     """Workflow version transition event"""
 
-    def __init__(self, object, workflow, old_object, source, destination, transition, comment):
-        super(WorkflowVersionTransitionEvent, self).__init__(object, workflow, source, destination, transition, comment)
+    def __init__(self, object, workflow, principal, old_object, source, destination, transition, comment):
+        super(WorkflowVersionTransitionEvent, self).__init__(object, workflow, principal, source,
+                                                             destination, transition, comment)
         self.old_object = old_object
 
 
@@ -163,6 +167,8 @@
     retired_states = Set(title="Retired states",
                          description="States of contents which are retired but not yet archived")
 
+    auto_retired_state = Attribute("Auto-retired state")
+
     def initialize(self):
         """Do any needed initialization.
 
@@ -201,7 +207,7 @@
         Fires a transition event.
         """
 
-    def fire_transition(self, transition_id, comment=None, side_effect=None, check_security=True):
+    def fire_transition(self, transition_id, comment=None, side_effect=None, check_security=True, principal=None):
         """Fire a transition for the context object.
 
         There's an optional comment parameter that contains some
@@ -220,7 +226,7 @@
         user's permission is.
         """
 
-    def fire_transition_toward(self, state, comment=None, side_effect=None, check_security=True):
+    def fire_transition_toward(self, state, comment=None, side_effect=None, check_security=True, principal=None):
         """Fire transition toward state.
 
         Looks up a manual transition that will get to the indicated
@@ -233,7 +239,7 @@
         AmbiguousTransitionError will be raised.
         """
 
-    def fire_transition_for_versions(self, state, transition_id, comment=None):
+    def fire_transition_for_versions(self, state, transition_id, comment=None, principal=None):
         """Fire a transition for all versions in a state"""
 
     def fire_automatic(self):
@@ -315,6 +321,9 @@
     history = List(title="Workflow states history",
                    value_type=Object(schema=IWorkflowStateHistoryItem))
 
+    def get_first_state_date(self, states):
+        """Get first date at which given state was set"""
+
 
 class IWorkflowVersions(Interface):
     """Interface to get information about versions of content in workflow"""
@@ -330,16 +339,16 @@
     def get_last_versions(self, count=1):
         """Get last versions of this object. Set count=0 to get all versions."""
 
-    def add_version(self, content, state):
+    def add_version(self, content, state, principal=None):
         """Return new unique version id"""
 
-    def set_state(self, version_id, state):
+    def set_state(self, version_id, state, principal=None):
         """Set new state for given version"""
 
     def has_version(self, state):
         """Return true if a version exists with the specific workflow state"""
 
-    def remove_version(self, version_id, state='deleted', comment=None):
+    def remove_version(self, version_id, state='deleted', comment=None, principal=None):
         """Remove version with given ID"""