Commit 6f9566f2 authored by Ayush Tiwari's avatar Ayush Tiwari

TemplateTool: Add fucntion for getting insalled Business Tempalte V2

parent 36492618
...@@ -147,23 +147,23 @@ class BusinessCommit(Folder): ...@@ -147,23 +147,23 @@ class BusinessCommit(Folder):
Installation: Installation:
- Check if the status is committed (Done by constraint of Business Commit - Check if the status is committed (Done by constraint of Business Commit
portal_type) portal_type)
- Check if there are installed Business Manager(s) because they will be - Check if there are installed Business Template V2(s) because they will be
required in building new Business Snapshot. Raise if there are None. required in building new Business Snapshot. Raise if there are None.
- Create an equivalent snapshot (using items of this commit and predecessors - Create an equivalent snapshot (using items of this commit and predecessors
belonging to installed Business Managers) belonging to installed Business Template V2s)
- TODO: Compare the snapshot with the last snapshot - TODO: Compare the snapshot with the last snapshot
- Install the snapshot - Install the snapshot
""" """
site = self.getPortalObject() site = self.getPortalObject()
portal_templates = site.portal_templates portal_templates = site.portal_templates
installed_bm_list = portal_templates.getInstalledBusinessManagerList() installed_bt_list = portal_templates.getInstalledBusinessTemplateV2List()
# Should raise if there is no installed BM in ZODB. Should install BM via # Should raise if there is no installed BM in ZODB. Should install BM via
# portal_templates first. # portal_templates first.
# XXX: Maybe instead of raising, we can provide an option to install BM # XXX: Maybe instead of raising, we can provide an option to install BM
# here only. So that a new user don't get confused ? # here only. So that a new user don't get confused ?
if not installed_bm_list: if not installed_bt_list:
raise ValueError('There is no installed BM to create snapshot') raise ValueError('There is no installed BT to create snapshot')
successor_list = self.getPredecessorRelatedValueList() successor_list = self.getPredecessorRelatedValueList()
...@@ -185,17 +185,17 @@ class BusinessCommit(Folder): ...@@ -185,17 +185,17 @@ class BusinessCommit(Folder):
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): def getBusinessTemplateV2List(self):
""" """
Give the list of all Business Manager(s) being touched by this Business Give the list of all Business Template V2(s) being touched by this Business
Commit Commit
""" """
manager_list = [] template_list = []
for item in self.objectValues(): for item in self.objectValues():
manager_list.extend(item.getFollowUpValueList()) template_list.extend(item.getFollowUpValueList())
return list(set(manager_list)) return list(set(template_list))
def getBusinessManagerTitleList(self): def getBusinessTemplateV2TitleList(self):
title_list = [l.getTitle() for l in self.getBusinessManagerList()] title_list = [l.getTitle() for l in self.getBusinessTemplateV2List()]
return title_list return title_list
...@@ -2420,6 +2420,19 @@ class TemplateTool (BaseTool): ...@@ -2420,6 +2420,19 @@ class TemplateTool (BaseTool):
installed_bm_title_list = [bm.title for bm in installed_bm_list] installed_bm_title_list = [bm.title for bm in installed_bm_list]
return installed_bm_title_list return installed_bm_title_list
def getInstalledBusinessTemplateV2List(self):
bt_list = self.objectValues(portal_type='Business Template V2')
installed_bt_list = [bt for bt in bt_list
if bt.getAvailabilityState() == 'installable']
return installed_bt_list
def getInstalledBusinessTemplateV2TitleList(self):
installed_bt_list = self.getInstalledBusinessManagerV2List()
if not len(installed_bt_list):
return []
installed_bt_title_list = [bt.getTitle() for bt in installed_bt_list]
return installed_bt_title_list
security.declareProtected(Permissions.ManagePortal, security.declareProtected(Permissions.ManagePortal,
'getBusinessTemplateUrl') 'getBusinessTemplateUrl')
def getBusinessTemplateUrl(self, base_url_list, bt5_title): def getBusinessTemplateUrl(self, base_url_list, bt5_title):
......
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