Commit 4dc7ad72 authored by Ayush Tiwari's avatar Ayush Tiwari

bt5_config: No need to recursively reduce in dependencies which are already BM

parent 87bcd6d9
...@@ -592,7 +592,7 @@ class TemplateTool (BaseTool): ...@@ -592,7 +592,7 @@ class TemplateTool (BaseTool):
importAndReExportBusinessTemplateFromPath(template_path) importAndReExportBusinessTemplateFromPath(template_path)
security.declareProtected( 'Import/Export objects', 'migrateBTToBM') security.declareProtected( 'Import/Export objects', 'migrateBTToBM')
def migrateBTToBM(self, template_path, REQUEST=None, **kw): def migrateBTToBM(self, template_path, isReduced=False, REQUEST=None, **kw):
""" """
Migrate business template repository to Business Manager repo. Migrate business template repository to Business Manager repo.
Business Manager completely rely only on BusinessItem and to show Business Manager completely rely only on BusinessItem and to show
...@@ -832,6 +832,9 @@ class TemplateTool (BaseTool): ...@@ -832,6 +832,9 @@ class TemplateTool (BaseTool):
Used for recursive udpation of layer for dependency in a BT Used for recursive udpation of layer for dependency in a BT
""" """
dependency_list = bt.getDependencyList() dependency_list = bt.getDependencyList()
# XXX: Do not return template_path_list of the new BM incase there is no
# dependency_list, instead look for the latest updated version of
# new_template_path_list
if not dependency_list: if not dependency_list:
return template_path_list return template_path_list
else: else:
...@@ -867,38 +870,34 @@ class TemplateTool (BaseTool): ...@@ -867,38 +870,34 @@ class TemplateTool (BaseTool):
# Check for the item list and if the BT is Business Manager, # Check for the item list and if the BT is Business Manager,
# if BM, then compare and update layer and if not run migration and # if BM, then compare and update layer and if not run migration and
# then do it again # then do it again
if base_bt.getPortalType() == 'Business Manager': if base_bt.getPortalType() != 'Business Manager':
# Check for item path which also exists in base_bt # If the base_bt is not Business Manager, run the migration on the
base_path_list = base_bt.getPathList() # base_bt
base_bt = self.migrateBTToBM(base_bt_path, isReduced=True)
copy_of_template_path_list = new_template_path_list[:]
# Loop through all the paths in the new_template_path_list and # Check for item path which also exists in base_bt
# check for their existence in base_path_list base_path_list = base_bt.getPathList()
for idx, path in enumerate(new_template_path_list):
path_list = path.split(' | ') copy_of_template_path_list = new_template_path_list[:]
item_path = path_list[0] # Loop through all the paths in the new_template_path_list and
item_layer = path_list[2] # check for their existence in base_path_list
if item_path in base_path_list: for idx, path in enumerate(new_template_path_list):
# TODO: Increase the layer of the path item by +1 and save it path_list = path.split(' | ')
# back at updated_template_path_list item_path = path_list[0]
item_layer = int(item_layer) + 1 item_layer = path_list[2]
updated_path = item_path + ' | 1 | ' + str(item_layer) if item_path in base_path_list:
copy_of_template_path_list[idx] = updated_path # TODO: Increase the layer of the path item by +1 and save it
new_template_path_list = copy_of_template_path_list # back at updated_template_path_list
item_layer = int(item_layer) + 1
if base_bt.getPortalType() != 'Business Manager': updated_path = item_path + ' | 1 | ' + str(item_layer)
# Recursively reduce the base Business Templatem no need to do copy_of_template_path_list[idx] = updated_path
# this for Business Manager(s) as it had already been migrated new_template_path_list = copy_of_template_path_list
# with taking care of layer
reduceDependencyList(base_bt, new_template_path_list) if base_bt.getPortalType() != 'Business Manager':
# Recursively reduce the base Business Templatem no need to do
# If the base_bt is not Business Manager, run the migration on the # this for Business Manager(s) as it had already been migrated
# base_bt # with taking care of layer
else: reduceDependencyList(base_bt, new_template_path_list)
# XXX: Just calling migrateBTToBM here won't do anything, we need
# to remove the BT from path and then update it with the migrated
# one
base_bt = self.migrateBTToBM(base_bt_path)
return new_template_path_list return new_template_path_list
...@@ -939,6 +938,9 @@ class TemplateTool (BaseTool): ...@@ -939,6 +938,9 @@ class TemplateTool (BaseTool):
if is_installed: if is_installed:
import_template.uninstall() import_template.uninstall()
if isReduced:
return migrated_bm
def cleanTemplatePathList(self, path_list): def cleanTemplatePathList(self, path_list):
""" """
Remove redundant paths and sub-objects' path if the object path already Remove redundant paths and sub-objects' path if the object path already
......
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