Commit 307c24d1 authored by Ayush Tiwari's avatar Ayush Tiwari

CommitTool: Installation should take care of states

parent a8b08028
...@@ -144,6 +144,7 @@ class BusinessCommit(Folder): ...@@ -144,6 +144,7 @@ class BusinessCommit(Folder):
- check if there is already an equivalent snapshot - check if there is already an equivalent snapshot
- if not, create one and install it - if not, create one and install it
""" """
site = self.getPortalObject()
successor_list = self.getPredecessorRelatedValueList() successor_list = self.getPredecessorRelatedValueList()
# Check if the successor list has a snapshot in it # Check if the successor list has a snapshot in it
...@@ -155,8 +156,26 @@ class BusinessCommit(Folder): ...@@ -155,8 +156,26 @@ class BusinessCommit(Folder):
# Create a new equivalent snapshot # Create a new equivalent snapshot
eqv_snapshot = self.createEquivalentSnapshot() eqv_snapshot = self.createEquivalentSnapshot()
for item in eqv_snapshot.objectValues(): # When installing Business Snapshot, installation state should be changed
item.install(self) if eqv_snapshot not in [None, self]:
if site.portal_workflow.isTransitionPossible(
eqv_snapshot, 'install'):
eqv_snapshot.install(self)
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()]
def getBusinessManagerList(self):
"""
Give the list of all Business Manager(s) being touched by this Business
Commit
"""
manager_list = []
for item in self.objectValues():
manager_list.extend(item.getFollowUpValueList())
return list(set(manager_list))
def getBusinessManagerTitleList(self):
title_list = [l.getTitle() for l in self.getBusinessManagerList()]
return title_list
...@@ -182,7 +182,16 @@ class CommitTool (BaseTool): ...@@ -182,7 +182,16 @@ class CommitTool (BaseTool):
def newContent(self, id=None, **kw): def newContent(self, id=None, **kw):
""" """
Override newContent so as to use 'id' generated like hash Override newContent so as to use 'id' generated like hash
Also, create new commit only when all old commits are committed
""" """
old_commit_list = self.objectValues(portal_type='Business Commit')
# Check if all the commits created before are commited or not
all_commited = all([l.getTranslatedValidationState() == 'commited'
for l in old_commit_list])
if not all_commited:
raise ValueError('Please commit your last commit before creating new one')
if id is None: if id is None:
id = uuid.uuid1() id = uuid.uuid1()
......
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