Commit d5130878 authored by Ayush Tiwari's avatar Ayush Tiwari

bt5_config: Function to get Diff in BusinessPatchItem objects

parent c4692bb4
...@@ -1177,6 +1177,11 @@ class BusinessPatchItem(XMLObject): ...@@ -1177,6 +1177,11 @@ class BusinessPatchItem(XMLObject):
item_layer = self.getProperty('item_layer') item_layer = self.getProperty('item_layer')
item_sign = self.getProperty('item_sign') item_sign = self.getProperty('item_sign')
# Remove old objects if it exists
old_id_list = [l for l in self.objectIds()]
if old_id_list:
self.manage_delObjects(ids=old_id_list)
# Get the dependency Business Manager # Get the dependency Business Manager
dependency_list = self.getProperty('dependency_list') dependency_list = self.getProperty('dependency_list')
if dependency_list: if dependency_list:
...@@ -1241,6 +1246,25 @@ class BusinessPatchItem(XMLObject): ...@@ -1241,6 +1246,25 @@ class BusinessPatchItem(XMLObject):
else: else:
return old_item.getProperty('item_property_value') return old_item.getProperty('item_property_value')
def getDiff(self):
"""
Use diff tool to find the diff between two values
XXX: For now we display the json format of the patched diff
"""
portal = self.getPortalObject()
diff_tool = portal.portal_diff
patch_format = 'deepdiff'
patch = diff_tool.diffPortalObject(old=self._getOb('old_item'),
new=self._getOb('new_item'),
patch_format=patch_format
)
if patch_format == 'deepdiff':
return patch.asDeepDiffPatch().json
else:
# For json-patch object
return patch.asJSONPatch().to_string()
def registerSkinFolder(skin_tool, skin_folder): def registerSkinFolder(skin_tool, skin_folder):
request = skin_tool.REQUEST request = skin_tool.REQUEST
# XXX: Getting parameter from request instead of dialog is bad # XXX: Getting parameter from request instead of dialog is bad
......
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