diff --git a/product/ERP5Type/Base.py b/product/ERP5Type/Base.py index 4a83c2bcd875dc43c61dc6c55b4521f801ff8000..efc89fc01c9f3737381001783915e706d2aab1d0 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):