Commit d5621890 authored by Jérome Perrin's avatar Jérome Perrin

If a business template refers to a skin selection that does not exists,

initialize it when installing the business template.



git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@16531 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 10eb605f
...@@ -1179,8 +1179,42 @@ class SkinTemplateItem(ObjectTemplateItem): ...@@ -1179,8 +1179,42 @@ class SkinTemplateItem(ObjectTemplateItem):
for obj in folder.objectValues(spec=('Z SQL Method',)): for obj in folder.objectValues(spec=('Z SQL Method',)):
fixZSQLMethod(p, obj) fixZSQLMethod(p, obj)
# Add new folders into skin paths.
ps = p.portal_skins ps = p.portal_skins
# Add new skin selection if not already existing
for relative_url in self._archive.keys():
if context.getTemplateFormatVersion() == 1:
if update_dict.has_key(relative_url) or force:
if not force:
if update_dict[relative_url] == 'nothing':
continue
obj = self._objects[relative_url]
else:
obj = self._archive[relative_url]
selection_list = obj.getProperty(
'business_template_registered_skin_selections', [])
if isinstance(selection_list, basestring):
selection_list = selection_list.split()
for skin_selection in selection_list:
if skin_selection not in ps.getSkinSelections():
# This skin selection does not exist, so we create a new one.
# We'll initialize it with all skin folders, unless:
# - they explictly define a list of
# "business_template_registered_skin_selections", and we
# are not in this list.
# - they are not registred in the default skin selection
skin_path = ''
for skin_folder in ps.objectValues():
if skin_selection in skin_folder.getProperty(
'business_template_registered_skin_selections',
(skin_selection, )):
if skin_folder.getId() in ps.getSkinPath(ps.getDefaultSkin()):
if skin_path:
skin_path = '%s,%s' % (skin_path, skin_folder.getId())
else:
skin_path= skin_folder.getId()
ps.addSkinSelection(skin_selection, skin_path)
# Add new folders into skin paths.
for skin_name, selection in ps.getSkinPaths(): for skin_name, selection in ps.getSkinPaths():
new_selection = [] new_selection = []
selection = selection.split(',') selection = selection.split(',')
......
...@@ -4195,6 +4195,56 @@ class TestBusinessTemplate(ERP5TypeTestCase, LogInterceptor): ...@@ -4195,6 +4195,56 @@ class TestBusinessTemplate(ERP5TypeTestCase, LogInterceptor):
sequence_list.addSequenceString(sequence_string) sequence_list.addSequenceString(sequence_string)
sequence_list.play(self, quiet=quiet) sequence_list.play(self, quiet=quiet)
def stepSetSkinFolderRegistredSelections(self, sequence=None, **kw):
ps = self.getSkinsTool()
skin_id = sequence.get('skin_folder_id')
skin_folder = ps._getOb(skin_id, None)
skin_folder._setProperty(
'business_template_registered_skin_selections', ('Foo',),
type='tokens')
def stepCheckSkinSelectionAdded(self, sequence=None, **kw):
ps = self.getSkinsTool()
skin_id = sequence.get('skin_folder_id')
skin_paths = ps.getSkinPaths()
# a new skin selection is added
self.assertTrue('Foo' in ps.getSkinSelections())
# and it contains good layers
layers = ps.getSkinPath('Foo').split(',')
self.assertTrue(skin_id in layers, layers)
self.assertTrue('erp5_core' in layers, layers)
self.assertFalse('erp5_xhtml_style' in layers, layers)
def test_33_BusinessTemplateWithNewSkinSelection(self, quiet=quiet,
run=run_all_test):
if not run: return
if not quiet:
message = 'Test Business Template With New Skin Selection'
ZopeTestCase._print('\n%s ' % message)
LOG('Testing... ', 0, message)
sequence_list = SequenceList()
sequence_string = '\
CreateSkinFolder \
SetSkinFolderRegistredSelections \
CreateNewBusinessTemplate \
UseExportBusinessTemplate \
AddSkinFolderToBusinessTemplate \
BuildBusinessTemplate \
SaveBusinessTemplate \
RemoveSkinFolder \
\
ImportBusinessTemplate \
UseImportBusinessTemplate \
InstallBusinessTemplate \
Tic \
\
CheckSkinSelectionAdded \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self, quiet=quiet)
def test_getInstalledBusinessTemplate(self): def test_getInstalledBusinessTemplate(self):
self.assertNotEquals(None, self.getPortal()\ self.assertNotEquals(None, self.getPortal()\
.portal_templates.getInstalledBusinessTemplate('erp5_core')) .portal_templates.getInstalledBusinessTemplate('erp5_core'))
......
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