Commit fb589044 authored by Ayush Tiwari's avatar Ayush Tiwari

bt5_config: Update Business Manager path_list whenever we edit Business Item via Business Commit

parent 3f1786d3
......@@ -196,7 +196,7 @@ class BusinessManager(Folder):
, 'filter_content_types' : 1
}
item_path_list = []
# Declarative security
security = ClassSecurityInfo()
security.declareObjectProtected(Permissions.AccessContentsInformation)
......@@ -210,6 +210,15 @@ class BusinessManager(Folder):
PropertySheet.Version,
)
# XXX: This explicit setter and getter should be replaced using property
# sheet.
def setItemPathList(self, value):
self.item_path_list = value
def getItemPathList(self):
return self.item_path_list
def getShortRevision(self):
return None
......@@ -725,6 +734,28 @@ class BusinessItem(XMLObject):
if 'item_path' in self._v_modified_property_dict:
self.build(self.aq_parent)
# Update the Business Manager with the path list everytime after editing
# item_path
manager = self.getFollowUpValue()
# Copy the path list for Business Manager and update it with new path
item_path_list = manager.getItemPathList()[:]
old_item_path = self._v_modified_property_dict.get('item_path')
if old_item_path and item_path_list:
if old_item_path in item_path_list:
for idx, item in enumerate(item_path_list):
if item == old_item_path:
item_path_list[idx] = self.getProperty('item_path')
else:
item_path_list.append(self.getProperty('item_path'))
else:
# If there is no old_item_path or if path_list is empty, we can just
# append the new_path in path_list
item_path_list.append(self.getProperty('item_path'))
# Update the manager with new path list
manager.setProperty('item_path_list', item_path_list)
def build(self, context, **kw):
"""
Extract value for the given path from the OFS
......
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