Commit 5601d655 authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

* add newest_only option in getRepositoryBusinessTemplateList() so that it...

* add newest_only option in getRepositoryBusinessTemplateList() so that it only returns the newest one for each business template title.
* reinstall option in updateBusinessTemplateFromUrl() just calls install(force=True).


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@43192 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 56c10ba8
......@@ -1026,7 +1026,8 @@ class TemplateTool (BaseTool):
security.declareProtected( Permissions.AccessContentsInformation,
'getRepositoryBusinessTemplateList' )
def getRepositoryBusinessTemplateList(self, update_only=False, **kw):
def getRepositoryBusinessTemplateList(self, update_only=False,
newest_only=False, **kw):
"""Get the list of Business Templates in repositories.
"""
version_state_title_dict = { 'new' : 'New', 'present' : 'Present',
......@@ -1036,7 +1037,7 @@ class TemplateTool (BaseTool):
template_list = []
template_item_list = []
if update_only:
if update_only or newest_only:
# First of all, filter Business Templates in repositories.
template_item_dict = {}
for repository, property_dict_list in self.repository_dict.items():
......@@ -1060,6 +1061,7 @@ class TemplateTool (BaseTool):
and property_dict['revision'] \
and int(previous_property_dict['revision']) < int(property_dict['revision']):
template_item_dict[title] = (repository, property_dict)
if update_only:
# Next, select only updated business templates.
for repository, property_dict in template_item_dict.values():
installed_bt = \
......@@ -1074,6 +1076,8 @@ class TemplateTool (BaseTool):
and property_dict['revision'] \
and int(installed_bt.getRevision()) < int(property_dict['revision']):
template_item_list.append((repository, property_dict))
else:
template_item_list = template_item_dict.values()
else:
for repository, property_dict_list in self.repository_dict.items():
for property_dict in property_dict_list:
......@@ -1237,11 +1241,8 @@ class TemplateTool (BaseTool):
BusinessTemplate_getModifiedObject = \
aq_base(getattr(self, 'BusinessTemplate_getModifiedObject'))
if not reinstall:
listbox_object_list = BusinessTemplate_getModifiedObject.__of__(imported_bt5)()
if reinstall:
log('Reinstall all items')
install_kw = dict.fromkeys(imported_bt5.getItemsList(), 'install')
else:
install_kw = {}
previous_bt5 = self.getInstalledBusinessTemplate(bt_title)
if previous_bt5 is not None and \
......@@ -1275,6 +1276,10 @@ class TemplateTool (BaseTool):
log('Execute %r' % before_triggered_bt5_id)
imported_bt5.unrestrictedTraverse(before_triggered_bt5_id)()
if reinstall:
imported_bt5.install(force=True,
update_catalog=update_catalog)
else:
imported_bt5.install(object_to_update=install_kw,
update_catalog=update_catalog)
......
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