[Erp5-report] r16531 - in /erp5/trunk/products/ERP5: Document/ tests/
nobody at svn.erp5.org
nobody at svn.erp5.org
Fri Sep 21 11:05:28 CEST 2007
Author: jerome
Date: Fri Sep 21 11:05:27 2007
New Revision: 16531
URL: http://svn.erp5.org?rev=16531&view=rev
Log:
If a business template refers to a skin selection that does not exists,
initialize it when installing the business template.
Modified:
erp5/trunk/products/ERP5/Document/BusinessTemplate.py
erp5/trunk/products/ERP5/tests/testBusinessTemplate.py
Modified: erp5/trunk/products/ERP5/Document/BusinessTemplate.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Document/BusinessTemplate.py?rev=16531&r1=16530&r2=16531&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Document/BusinessTemplate.py (original)
+++ erp5/trunk/products/ERP5/Document/BusinessTemplate.py Fri Sep 21 11:05:27 2007
@@ -1179,8 +1179,42 @@
for obj in folder.objectValues(spec=('Z SQL Method',)):
fixZSQLMethod(p, obj)
+ 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.
- ps = p.portal_skins
for skin_name, selection in ps.getSkinPaths():
new_selection = []
selection = selection.split(',')
Modified: erp5/trunk/products/ERP5/tests/testBusinessTemplate.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/tests/testBusinessTemplate.py?rev=16531&r1=16530&r2=16531&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/tests/testBusinessTemplate.py (original)
+++ erp5/trunk/products/ERP5/tests/testBusinessTemplate.py Fri Sep 21 11:05:27 2007
@@ -4194,6 +4194,56 @@
'
sequence_list.addSequenceString(sequence_string)
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):
self.assertNotEquals(None, self.getPortal()\
More information about the Erp5-report
mailing list