Commit 14f43740 authored by Ayush Tiwari's avatar Ayush Tiwari

CommitTool: Use catalog to get last snapshot

parent 82c9b260
...@@ -733,22 +733,6 @@ class BusinessItem(XMLObject): ...@@ -733,22 +733,6 @@ class BusinessItem(XMLObject):
icon = None icon = None
isProperty = False isProperty = False
security.declareProtected(Permissions.ModifyPortalContent, 'edit')
def edit(self, item_path='', item_sign=1, item_layer=0, *args, **kw):
"""
Generic edit Method for all ERP5 object
"""
edited_value = self._edit(
item_path=item_path,
item_sign=item_sign,
item_layer=item_layer,
*args,
**kw)
# TODO: Use activity to update follow_up of Business Item as the portal_category
# accessor is generated
# Update the follow up value for Business Manager
self.updateFollowUpPathList()
def _edit(self, item_path='', item_sign=1, item_layer=0, *args, **kw): def _edit(self, item_path='', item_sign=1, item_layer=0, *args, **kw):
""" """
Overriden function so that we can update attributes for BusinessItem objects Overriden function so that we can update attributes for BusinessItem objects
...@@ -765,10 +749,6 @@ class BusinessItem(XMLObject): ...@@ -765,10 +749,6 @@ class BusinessItem(XMLObject):
if 'item_path' in self._v_modified_property_dict: if 'item_path' in self._v_modified_property_dict:
self.build(self.aq_parent) self.build(self.aq_parent)
# Update the Business Manager with the path list everytime after editing
# item_path. Use activity to call this function after the activitiy for
# _edit is finished.
def updateFollowUpPathList(self): def updateFollowUpPathList(self):
""" """
Update the path list for Follow Up Business Manager Update the path list for Follow Up Business Manager
...@@ -794,6 +774,10 @@ class BusinessItem(XMLObject): ...@@ -794,6 +774,10 @@ class BusinessItem(XMLObject):
# Update the manager with new path list # Update the manager with new path list
manager.setItemPathList(item_path_list) manager.setItemPathList(item_path_list)
else:
# Complain loudly if the follow_up is not there
raise ValueError('Follow Up Business Manager is not set or defined yet')
def build(self, context, **kw): def build(self, context, **kw):
""" """
Extract value for the given path from the OFS Extract value for the given path from the OFS
......
...@@ -137,14 +137,16 @@ class BusinessSnapshot(Folder): ...@@ -137,14 +137,16 @@ class BusinessSnapshot(Folder):
portal = self.getPortalObject() portal = self.getPortalObject()
commit_tool = portal.portal_commits commit_tool = portal.portal_commits
# Get the snapshot list except the current snapshot # XXX: Is it a good idea to be dependent on portal_catalog to get Snapshot list ?
snapshot_list = [l for l snapshot_list = commit_tool.searchFolder(
in commit_tool.objectValues(portal_type='Business Snapshot') portal_type='Business Snapshot',
if l != self] validation_state='installed'
)
if snapshot_list: # There should never be more than 1 installed snapshot
# Get the last created/installed snapshot comparing creation_date if len(snapshot_list) == 1:
return max(snapshot_list, key=(lambda x: x.getCreationDate())) # Get the last installed snapshot
return snapshot_list[0].getObject()
return None return None
...@@ -222,7 +224,9 @@ class BusinessSnapshot(Folder): ...@@ -222,7 +224,9 @@ class BusinessSnapshot(Folder):
Install the sub-objects in the commit Install the sub-objects in the commit
""" """
site = self.getPortalObject() site = self.getPortalObject()
# While installing the last snapshot state should be changed to 'replaced'
# While installing a new snapshot, last snapshot state should be
# changed to 'replaced'
last_snapshot = self.getLastSnapshot() last_snapshot = self.getLastSnapshot()
if last_snapshot not in [None, self]: if last_snapshot not in [None, self]:
if site.portal_workflow.isTransitionPossible( if site.portal_workflow.isTransitionPossible(
......
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