From 6968aae5b086057b9778531f9c4b52de11cc616a Mon Sep 17 00:00:00 2001 From: Jean-Paul Smets <jp@nexedi.com> Date: Tue, 6 Dec 2005 22:34:57 +0000 Subject: [PATCH] FIrst implementatoin of vorklow based getCreationDate and getModificationDate git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@4517 20353a03-c40f-0410-a6d1-a30d3c3de9de --- product/ERP5Type/Base.py | 62 ++++++++++++++++++++++++---------------- 1 file changed, 38 insertions(+), 24 deletions(-) diff --git a/product/ERP5Type/Base.py b/product/ERP5Type/Base.py index 4a83c2bcd8..efc89fc01c 100755 --- a/product/ERP5Type/Base.py +++ b/product/ERP5Type/Base.py @@ -2048,7 +2048,7 @@ class Base( CopyContainer, PortalContent, ActiveObject, ERP5PropertyManager ): def _temp_getTitle(self): return getattr(self,'title',None) - def log(self,description,content): + def log(self, description, content): """ Put a log message """ @@ -2056,29 +2056,6 @@ class Base( CopyContainer, PortalContent, ActiveObject, ERP5PropertyManager ): security.declareProtected(Permissions.ModifyPortalContent,'setDescription') - # Creation and modification date support through workflow - security.declareProtected(Permissions.AccessContentsInformation, 'getCreationDate') - def getCreationDate(self): - """ - Returns the creation date of the document based on workflow information - """ - # XXX To be implemenented - # Check if edit workflow defined - # Return none if not (or get it from parent ?) - # Then get the first line of edit_workflow - return None - - security.declareProtected(Permissions.AccessContentsInformation, 'getModificationDate') - def getModificationDate(self): - """ - Returns the modification date of the document based on workflow information - """ - # XXX To be implemenented - # Check if edit workflow defined - # Return none if not (or get it from parent ?) - # Then get the first line of edit_workflow - return None - # Dublin Core Emulation for CMF interoperatibility # CMF Dublin Core Compatibility def Title(self): @@ -2111,6 +2088,43 @@ class Base( CopyContainer, PortalContent, ActiveObject, ERP5PropertyManager ): def Rights(self): return self.getRight('') + # Creation and modification date support through workflow + security.declareProtected(Permissions.AccessContentsInformation, 'getCreationDate') + def getCreationDate(self): + """ + Returns the creation date of the document based on workflow information + """ + # Check if edit_workflow defined + portal_workflow = getToolByName(self, 'portal_workflow') + wf = portal_workflow.getWorkflowById('edit_workflow') + wf_list = list(portal_workflow.getWorkflowsFor(self)) + if wf is not None: wf_list = [wf] + wf_list + for wf in portal_workflow.getWorkflowsFor(self): + history = wf.getInfoFor(self, 'history', None) + if history is not None: + if len(history): + # Then get the first line of edit_workflow + return history[0].get('time', None) + return None + + security.declareProtected(Permissions.AccessContentsInformation, 'getModificationDate') + def getModificationDate(self): + """ + Returns the modification date of the document based on workflow information + """ + # Check if edit_workflow defined + portal_workflow = getToolByName(self, 'portal_workflow') + wf = portal_workflow.getWorkflowById('edit_workflow') + wf_list = list(portal_workflow.getWorkflowsFor(self)) + if wf is not None: wf_list = [wf] + wf_list + for wf in portal_workflow.getWorkflowsFor(self): + history = wf.getInfoFor(self, 'history', None) + if history is not None: + if len(history): + # Then get the first line of edit_workflow + return history[-1].get('time', None) + return None + InitializeClass(Base) class TempBase(Base): -- 2.30.9