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

Merge remote-tracking branch 'upstream/master' into zope4py2

parents 2042bdf4 de8ed690
...@@ -3295,6 +3295,16 @@ class TestBusinessTemplate(BusinessTemplateMixin): ...@@ -3295,6 +3295,16 @@ class TestBusinessTemplate(BusinessTemplateMixin):
"""Tests the Title of the Template Tool.""" """Tests the Title of the Template Tool."""
self.assertEqual('Business Templates', self.getTemplateTool().Title()) self.assertEqual('Business Templates', self.getTemplateTool().Title())
def test_business_template_properties_sorted(self):
bt = self.portal.portal_templates.newContent(
portal_type='Business Template')
bt.edit(template_path_list=['b', 'c', 'a'])
self.assertEqual(bt.getTemplatePathList(), ['a', 'b', 'c'])
bt.edit(template_keep_workflow_path_list=['b', 'c', 'a'])
self.assertEqual(bt.getTemplateKeepWorkflowPathList(), ['a', 'b', 'c'])
bt.edit(template_keep_last_workflow_history_only_path_list=['b', 'c', 'a'])
self.assertEqual(bt.getTemplateKeepLastWorkflowHistoryOnlyPathList(), ['a', 'b', 'c'])
def test_01_checkNewSite(self): def test_01_checkNewSite(self):
"""Test Check New Site""" """Test Check New Site"""
sequence_list = SequenceList() sequence_list = SequenceList()
...@@ -6812,7 +6822,7 @@ class TestBusinessTemplate(BusinessTemplateMixin): ...@@ -6812,7 +6822,7 @@ class TestBusinessTemplate(BusinessTemplateMixin):
portal_type='Business Template', portal_type='Business Template',
title=self.id(), title=self.id(),
template_path_list=( template_path_list=(
'portal_categories/test_category/**' 'portal_categories/test_category/**',
), ),
template_base_category_list=['test_category'], template_base_category_list=['test_category'],
) )
...@@ -6883,7 +6893,7 @@ class TestBusinessTemplate(BusinessTemplateMixin): ...@@ -6883,7 +6893,7 @@ class TestBusinessTemplate(BusinessTemplateMixin):
portal_type='Business Template', portal_type='Business Template',
title=self.id(), title=self.id(),
template_path_list=( template_path_list=(
'portal_categories/test_category/**' 'portal_categories/test_category/**',
), ),
template_base_category_list=['test_category'], template_base_category_list=['test_category'],
) )
......
...@@ -5,7 +5,8 @@ portal = context.getPortalObject() ...@@ -5,7 +5,8 @@ portal = context.getPortalObject()
if skin_folder_name not in portal.portal_skins.objectIds(): if skin_folder_name not in portal.portal_skins.objectIds():
portal.portal_skins.manage_addFolder(skin_folder_name) portal.portal_skins.manage_addFolder(skin_folder_name)
if skin_folder_name not in (context.getTemplateSkinIdList() or []): if skin_folder_name not in (context.getTemplateSkinIdList() or []):
context.setTemplateSkinIdList(tuple(context.getTemplateSkinIdList() or []) + (skin_folder_name, )) context.setTemplateSkinIdList(
sorted(tuple(context.getTemplateSkinIdList() or []) + (skin_folder_name, )))
skin_folder = portal.portal_skins[skin_folder_name] skin_folder = portal.portal_skins[skin_folder_name]
...@@ -30,7 +31,8 @@ if skin_layer_list: ...@@ -30,7 +31,8 @@ if skin_layer_list:
registered_skin = '%s | %s' % (skin_folder_name, skin_name) registered_skin = '%s | %s' % (skin_folder_name, skin_name)
registered_skin_selection_list = context.getTemplateRegisteredSkinSelectionList() or [] registered_skin_selection_list = context.getTemplateRegisteredSkinSelectionList() or []
if registered_skin not in registered_skin_selection_list: if registered_skin not in registered_skin_selection_list:
context.setTemplateRegisteredSkinSelectionList(tuple(registered_skin_selection_list) + (registered_skin, )) context.setTemplateRegisteredSkinSelectionList(
sorted(tuple(registered_skin_selection_list) + (registered_skin, )))
if not all_skin_layers_selected: if not all_skin_layers_selected:
marker = [] marker = []
......
...@@ -99,9 +99,11 @@ type_information.addAction( ...@@ -99,9 +99,11 @@ type_information.addAction(
# Associate the dialog with type information in business template meta data # Associate the dialog with type information in business template meta data
if context.getPortalType() == 'Business Template' and \ if context.getPortalType() == 'Business Template' and \
context.getInstallationState() != 'installed': context.getInstallationState() != 'installed':
context.setTemplateActionPathList(context.getTemplateActionPathList() + context.setTemplateActionPathList(
sorted(
tuple(context.getTemplateActionPathList()) +
('%s | %s' % (portal_type, action_id), ('%s | %s' % (portal_type, action_id),
'%s | %s' % (portal_type, action_id.replace('_report', '_export')), )) '%s | %s' % (portal_type, action_id.replace('_report', '_export')))))
# Create the report # Create the report
skin_folder.manage_addProduct['ERP5Form'].addERP5Report(report_form_name, report_name) skin_folder.manage_addProduct['ERP5Form'].addERP5Report(report_form_name, report_name)
......
...@@ -76,9 +76,10 @@ class TestBusinessTemplateScripts(ERP5TypeTestCase): ...@@ -76,9 +76,10 @@ class TestBusinessTemplateScripts(ERP5TypeTestCase):
# actions were added to business template # actions were added to business template
self.assertEqual( self.assertEqual(
( [
'Foo Module | dummy_export_export', 'Foo Module | dummy_export_export',
'Foo Module | dummy_report_report'), 'Foo Module | dummy_report_report',
],
self.business_template.getTemplateActionPathList(), self.business_template.getTemplateActionPathList(),
) )
...@@ -97,7 +98,7 @@ class TestBusinessTemplateScripts(ERP5TypeTestCase): ...@@ -97,7 +98,7 @@ class TestBusinessTemplateScripts(ERP5TypeTestCase):
self.assertIn('dummy_skin_folder', self.portal.portal_skins.objectIds()) self.assertIn('dummy_skin_folder', self.portal.portal_skins.objectIds())
# skin is added to business template # skin is added to business template
self.assertEqual( self.assertEqual(
('dummy_skin_folder', 'existing'), ['dummy_skin_folder', 'existing'],
self.business_template.getTemplateSkinIdList()) self.business_template.getTemplateSkinIdList())
def test_BusinessTemplate_createSkinFolder_priority(self): def test_BusinessTemplate_createSkinFolder_priority(self):
...@@ -154,8 +155,8 @@ class TestBusinessTemplateScripts(ERP5TypeTestCase): ...@@ -154,8 +155,8 @@ class TestBusinessTemplateScripts(ERP5TypeTestCase):
# skin is added to business template # skin is added to business template
self.assertEqual( self.assertEqual(
( [
'dummy_skin_folder | SelectedSkinSelection', 'dummy_skin_folder | SelectedSkinSelection',
'dummy_skin_folder | View', 'dummy_skin_folder | View',
'existing | SelectedSkinSelection', 'existing | SelectedSkinSelection',
), self.business_template.getTemplateRegisteredSkinSelectionList()) ], self.business_template.getTemplateRegisteredSkinSelectionList())
...@@ -45,6 +45,7 @@ from Products.CMFCore.utils import getToolByName ...@@ -45,6 +45,7 @@ from Products.CMFCore.utils import getToolByName
from Products.PythonScripts.PythonScript import PythonScript from Products.PythonScripts.PythonScript import PythonScript
from Products.ZSQLMethods.SQL import SQL from Products.ZSQLMethods.SQL import SQL
from Products.ERP5Type.Accessor.Constant import PropertyGetter as ConstantGetter from Products.ERP5Type.Accessor.Constant import PropertyGetter as ConstantGetter
from Products.ERP5Type.Accessor.TypeDefinition import asList
from Products.ERP5Type.Cache import transactional_cached from Products.ERP5Type.Cache import transactional_cached
from Products.ERP5Type.Message import translateString from Products.ERP5Type.Message import translateString
from Products.ERP5Type.UnrestrictedMethod import super_user from Products.ERP5Type.UnrestrictedMethod import super_user
...@@ -5578,185 +5579,39 @@ Business Template is a set of definitions, such as skins, portal types and categ ...@@ -5578,185 +5579,39 @@ Business Template is a set of definitions, such as skins, portal types and categ
download=1) download=1)
return export_string return export_string
def _getOrderedList(self, id): def _edit(self, *args, **kw):
""" """Make sure UI stores list properties as sorted.
We have to set this method because we want an """
ordered list edit_kw = {}
""" for k, v in six.iteritems(kw):
method_id = '_baseGet%sList' % convertToUpperCase(id) if v and k in (
result = getattr(self, method_id)(()) 'template_action_path_list',
if result is None: result = () 'template_base_category_list',
if result != (): 'template_catalog_method_id_list',
result = list(result) 'template_local_role_list',
result.sort() 'template_message_translation_list',
# XXX Why do we need to return a tuple ? 'template_module_id_list',
result = tuple(result) 'template_path_list',
return result 'template_keep_path_list',
'template_keep_workflow_path_list',
security.declareProtected(Permissions.AccessContentsInformation, 'getTemplateCatalogMethodIdList') 'template_keep_last_workflow_history_only_path_list',
def getTemplateCatalogMethodIdList(self): 'template_portal_type_allowed_content_type_list',
""" 'template_portal_type_base_category_list',
We have to set this method because we want an 'template_portal_type_hidden_content_type_list',
ordered list 'template_portal_type_id_list',
""" 'template_portal_type_property_sheet_list',
return self._getOrderedList('template_catalog_method_id') 'template_portal_type_role_list',
'template_portal_type_workflow_chain_list',
security.declareProtected(Permissions.AccessContentsInformation, 'getTemplateBaseCategoryList') 'template_preference_list',
def getTemplateBaseCategoryList(self): 'template_registered_skin_selection_list',
""" 'template_registered_version_priority_selection_list',
We have to set this method because we want an 'template_skin_id_list',
ordered list 'template_tool_id_list',
""" 'template_workflow_id_list',
return self._getOrderedList('template_base_category') ):
v = sorted(asList(v))
security.declareProtected(Permissions.AccessContentsInformation, 'getTemplateWorkflowIdList') edit_kw[k] = v
def getTemplateWorkflowIdList(self): return super(BusinessTemplate, self)._edit(*args, **edit_kw)
"""
We have to set this method because we want an
ordered list
"""
return self._getOrderedList('template_workflow_id')
security.declareProtected(Permissions.AccessContentsInformation, 'getTemplatePortalTypeIdList')
def getTemplatePortalTypeIdList(self):
"""
We have to set this method because we want an
ordered list
"""
return self._getOrderedList('template_portal_type_id')
security.declareProtected(Permissions.AccessContentsInformation, 'getTemplatePortalTypeWorkflowChainList')
def getTemplatePortalTypeWorkflowChainList(self):
"""
We have to set this method because we want an
ordered list
"""
return self._getOrderedList('template_portal_type_workflow_chain')
security.declareProtected(Permissions.AccessContentsInformation, 'getTemplatePathList')
def getTemplatePathList(self):
"""
We have to set this method because we want an
ordered list
"""
return self._getOrderedList('template_path')
security.declareProtected(Permissions.AccessContentsInformation, 'getTemplatePreferenceList')
def getTemplatePreferenceList(self):
"""
We have to set this method because we want an
ordered list
"""
return self._getOrderedList('template_preference')
security.declareProtected(Permissions.AccessContentsInformation, 'getTemplatePortalTypeAllowedContentTypeList')
def getTemplatePortalTypeAllowedContentTypeList(self):
"""
We have to set this method because we want an
ordered list
"""
return self._getOrderedList('template_portal_type_allowed_content_type')
security.declareProtected(Permissions.AccessContentsInformation, 'getTemplatePortalTypeHiddenContentTypeList')
def getTemplatePortalTypeHiddenContentTypeList(self):
"""
We have to set this method because we want an
ordered list
"""
return self._getOrderedList('template_portal_type_hidden_content_type')
security.declareProtected(Permissions.AccessContentsInformation, 'getTemplatePortalTypePropertySheetList')
def getTemplatePortalTypePropertySheetList(self):
"""
We have to set this method because we want an
ordered list
"""
return self._getOrderedList('template_portal_type_property_sheet')
security.declareProtected(Permissions.AccessContentsInformation, 'getTemplatePortalTypeBaseCategoryList')
def getTemplatePortalTypeBaseCategoryList(self):
"""
We have to set this method because we want an
ordered list
"""
return self._getOrderedList('template_portal_type_base_category')
security.declareProtected(Permissions.AccessContentsInformation, 'getTemplateActionPathList')
def getTemplateActionPathList(self):
"""
We have to set this method because we want an
ordered list
"""
return self._getOrderedList('template_action_path')
security.declareProtected(Permissions.AccessContentsInformation, 'getTemplatePortalTypeRoleList')
def getTemplatePortalTypeRoleList(self):
"""
We have to set this method because we want an
ordered list
"""
return self._getOrderedList('template_portal_type_role')
security.declareProtected(Permissions.AccessContentsInformation, 'getTemplateLocalRoleList')
def getTemplateLocalRoleList(self):
"""
We have to set this method because we want an
ordered list
"""
return self._getOrderedList('template_local_role')
security.declareProtected(Permissions.AccessContentsInformation, 'getTemplateSkinIdList')
def getTemplateSkinIdList(self):
"""
We have to set this method because we want an
ordered list
"""
return self._getOrderedList('template_skin_id')
security.declareProtected(Permissions.AccessContentsInformation, 'getTemplateRegisteredSkinSelectionList')
def getTemplateRegisteredSkinSelectionList(self):
"""
We have to set this method because we want an
ordered list
"""
return self._getOrderedList('template_registered_skin_selection')
security.declareProtected(Permissions.AccessContentsInformation, 'getTemplateRegisteredVersionPrioritySelectionList')
def getTemplateRegisteredVersionPrioritySelectionList(self):
"""
We have to set this method because we want an
ordered list
"""
try:
return self._getOrderedList('template_registered_version_priority_selection')
# This property may not be defined if erp5_property_sheets has not been
# upgraded yet
except AttributeError:
return ()
security.declareProtected(Permissions.AccessContentsInformation, 'getTemplateModuleIdList')
def getTemplateModuleIdList(self):
"""
We have to set this method because we want an
ordered list
"""
return self._getOrderedList('template_module_id')
security.declareProtected(Permissions.AccessContentsInformation, 'getTemplateMessageTranslationList')
def getTemplateMessageTranslationList(self):
"""
We have to set this method because we want an
ordered list
"""
return self._getOrderedList('template_message_translation')
security.declareProtected(Permissions.AccessContentsInformation, 'getTemplateToolIdList')
def getTemplateToolIdList(self):
"""
We have to set this method because we want an
ordered list
"""
return self._getOrderedList('template_tool_id')
def _isInKeepList(self, keep_list, path): def _isInKeepList(self, keep_list, path):
for keep_path in keep_list: for keep_path in keep_list:
......
...@@ -70,7 +70,6 @@ if WITH_LEGACY_WORKFLOW: ...@@ -70,7 +70,6 @@ if WITH_LEGACY_WORKFLOW:
from Products.ERP5Type.patches import StateChangeInfoPatch from Products.ERP5Type.patches import StateChangeInfoPatch
from Products.ERP5Type.patches import transforms from Products.ERP5Type.patches import transforms
from Products.ERP5Type.patches import OFSPdata from Products.ERP5Type.patches import OFSPdata
from Products.ERP5Type.patches import make_hidden_input
from Products.ERP5Type.patches import DemoStorage from Products.ERP5Type.patches import DemoStorage
from Products.ERP5Type.patches import unicodeconflictresolver from Products.ERP5Type.patches import unicodeconflictresolver
from Products.ERP5Type.patches import ZODBConnection from Products.ERP5Type.patches import ZODBConnection
......
##############################################################################
#
# Copyright (c) 2002 Zope Corporation and Contributors. All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
#
##############################################################################
"""
Close properly the <input /> tag
"""
import ZTUtils.Zope
from ZTUtils.Zope import complex_marshal
from Products.PythonScripts.standard import html_quote
from Products.ERP5Type.Utils import ensure_list
def make_hidden_input(*args, **kwargs):
'''Construct a set of hidden input elements, with marshalling markup.
If there are positional arguments, they must be dictionaries.
They are combined with the dictionary of keyword arguments to form
a dictionary of query names and values.
Query names (the keys) must be strings. Values may be strings,
integers, floats, or DateTimes, and they may also be lists or
namespaces containing these types. All arguments are marshalled with
complex_marshal().
'''
d = {}
for arg in args:
d.update(arg)
d.update(kwargs)
hq = lambda x: html_quote(x)
qlist = complex_marshal(ensure_list(d.items()))
for i in range(len(qlist)):
k, m, v = qlist[i]
qlist[i] = ('<input type="hidden" name="%s%s" value="%s" />'
% (hq(k), m, hq(str(v))))
return '\n'.join(qlist)
ZTUtils.Zope.make_hidden_input = make_hidden_input
ZTUtils.make_hidden_input = make_hidden_input
...@@ -597,23 +597,6 @@ class ERP5TypeTestCaseMixin(ProcessingNodeTestCase, PortalTestCase): ...@@ -597,23 +597,6 @@ class ERP5TypeTestCaseMixin(ProcessingNodeTestCase, PortalTestCase):
bt5_path_list += [os.path.join(path, "*") for path in bt5_path_list] bt5_path_list += [os.path.join(path, "*") for path in bt5_path_list]
def search(path, template): def search(path, template):
parsed_url = six.moves.urllib.parse.urlparse(path + '/' + template)
if parsed_url.scheme == 'http':
user = parsed_url.username
password = parsed_url.password
host = parsed_url.hostname
selector = parsed_url.path
h = http_client.HTTP(host)
h.putrequest('HEAD', selector)
h.putheader('Host', host)
if user and passwd:
h.putheader('Authorization',
'Basic %s' % base64.b64encode(str2bytes('%s:%s' % (user, passwd))).strip())
h.endheaders()
errcode, errmsg, headers = h.getreply()
if errcode == 200:
return urltype + ':' + url
else:
path_list = glob(os.path.join(path, template)) path_list = glob(os.path.join(path, template))
if path_list: if path_list:
return path_list[0] return path_list[0]
......
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