Commit 18479443 authored by Ayush Tiwari's avatar Ayush Tiwari

bt5_prototype: Update template tool download function with parameter to check for portal_type

parent 640bbe02
...@@ -101,7 +101,7 @@ class TemplateTool (BaseTool): ...@@ -101,7 +101,7 @@ class TemplateTool (BaseTool):
title = 'Template Tool' title = 'Template Tool'
meta_type = 'ERP5 Template Tool' meta_type = 'ERP5 Template Tool'
portal_type = 'Template Tool' portal_type = 'Template Tool'
allowed_types = ('ERP5 Business Template', ) allowed_types = ('ERP5 Business Template', 'ERP5 Business Package')
# This stores information on repositories. # This stores information on repositories.
repository_dict = {} repository_dict = {}
...@@ -321,9 +321,14 @@ class TemplateTool (BaseTool): ...@@ -321,9 +321,14 @@ class TemplateTool (BaseTool):
REQUEST.RESPONSE.redirect("%s?portal_status_message=%s" REQUEST.RESPONSE.redirect("%s?portal_status_message=%s"
% (ret_url, psm)) % (ret_url, psm))
def _download_local(self, path, bt_id): def _download_local(self, path, bt_id, isPackage=False):
"""Download Business Template from local directory or file """Download Business Template from local directory or file
""" """
if isPackage:
bp = self.newContent(bt_id, 'Business Package')
bp.importFile(path)
return bp
bt = self.newContent(bt_id, 'Business Template') bt = self.newContent(bt_id, 'Business Template')
bt.importFile(path) bt.importFile(path)
return bt return bt
...@@ -353,7 +358,7 @@ class TemplateTool (BaseTool): ...@@ -353,7 +358,7 @@ class TemplateTool (BaseTool):
shutil.rmtree(svn_checkout_tmp_dir) shutil.rmtree(svn_checkout_tmp_dir)
security.declareProtected( 'Import/Export objects', 'download' ) security.declareProtected( 'Import/Export objects', 'download' )
def download(self, url, id=None, REQUEST=None): def download(self, url, id=None, REQUEST=None, isPackage=False):
""" """
Download Business Template from url, can be file or local directory Download Business Template from url, can be file or local directory
""" """
...@@ -361,7 +366,6 @@ class TemplateTool (BaseTool): ...@@ -361,7 +366,6 @@ class TemplateTool (BaseTool):
# come from the management interface. # come from the management interface.
if REQUEST is not None: if REQUEST is not None:
return self.manage_download(url, id=id, REQUEST=REQUEST) return self.manage_download(url, id=id, REQUEST=REQUEST)
if id is None: if id is None:
id = self.generateNewId() id = self.generateNewId()
...@@ -378,7 +382,7 @@ class TemplateTool (BaseTool): ...@@ -378,7 +382,7 @@ class TemplateTool (BaseTool):
return self[self._setObject(id, bt)] return self[self._setObject(id, bt)]
bt = self._download_url(url, id) bt = self._download_url(url, id)
else: else:
bt = self._download_local(os.path.normpath(name), id) bt = self._download_local(os.path.normpath(name), id, isPackage)
bt.build(no_action=True) bt.build(no_action=True)
return bt return bt
......
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