Commit 82c9b260 authored by Ayush Tiwari's avatar Ayush Tiwari

CommitTool: Update workflow status of old snapshot before installling a new snapshot

parent 9b9a1a03
...@@ -160,7 +160,7 @@ class BusinessCommit(Folder): ...@@ -160,7 +160,7 @@ class BusinessCommit(Folder):
if eqv_snapshot not in [None, self]: if eqv_snapshot not in [None, self]:
if site.portal_workflow.isTransitionPossible( if site.portal_workflow.isTransitionPossible(
eqv_snapshot, 'install'): eqv_snapshot, 'install'):
eqv_snapshot.install(self) eqv_snapshot.install()
def getItemPathList(self): def getItemPathList(self):
return [l.getProperty('item_path') for l in self.objectValues()] return [l.getProperty('item_path') for l in self.objectValues()]
......
...@@ -114,7 +114,25 @@ class BusinessSnapshot(Folder): ...@@ -114,7 +114,25 @@ class BusinessSnapshot(Folder):
PropertySheet.Version, PropertySheet.Version,
) )
def getItemList(self):
"""
Returns the collection of all Business Item, Business Property Item and
Business Patch item at the given snapshot.
"""
return self.objectValues()
def getItemPathList(self):
"""
Returns the path of all Business Item, Business Property Item and
Business Patch item at the given snapshot.
"""
return [l.getProperty('item_path') for l in self.getItemList()]
def getLastSnapshot(self): def getLastSnapshot(self):
"""
Get last snapshot exisiting.
Returns None if there is no last snapshot.
"""
portal = self.getPortalObject() portal = self.getPortalObject()
commit_tool = portal.portal_commits commit_tool = portal.portal_commits
...@@ -130,20 +148,6 @@ class BusinessSnapshot(Folder): ...@@ -130,20 +148,6 @@ class BusinessSnapshot(Folder):
return None return None
def getItemList(self):
"""
Returns the collection of all Business Item, Business Property Item and
Business Patch item at the given snapshot.
"""
return self.objectValues()
def getItemPathList(self):
"""
Returns the path of all Business Item, Business Property Item and
Business Patch item at the given snapshot.
"""
return [l.getProperty('item_path') for l in self.getItemList()]
def buildSnapshot(self): def buildSnapshot(self):
""" """
Using equivalent commit, create a snapshot of ZODB state Using equivalent commit, create a snapshot of ZODB state
...@@ -217,5 +221,14 @@ class BusinessSnapshot(Folder): ...@@ -217,5 +221,14 @@ class BusinessSnapshot(Folder):
""" """
Install the sub-objects in the commit Install the sub-objects in the commit
""" """
site = self.getPortalObject()
# While installing the last snapshot state should be changed to 'replaced'
last_snapshot = self.getLastSnapshot()
if last_snapshot not in [None, self]:
if site.portal_workflow.isTransitionPossible(
last_snapshot, 'replace'):
last_snapshot.replace(self)
# Now install the items in new snapshot
for item in self.objectValues(): for item in self.objectValues():
item.install(self) item.install(self)
...@@ -159,8 +159,8 @@ class CommitTool (BaseTool): ...@@ -159,8 +159,8 @@ class CommitTool (BaseTool):
meta_type = 'ERP5 Commit Tool' meta_type = 'ERP5 Commit Tool'
portal_type = 'Commit Tool' portal_type = 'Commit Tool'
allowed_types = ( allowed_types = (
'ERP5 Business Commit', 'Business Commit',
'ERP5 Business Snapshot', 'Business Snapshot',
) )
# This stores information on repositories. # This stores information on repositories.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment