Commit 984f57ea authored by Jérome Perrin's avatar Jérome Perrin

fix a regression from 35110.

In this commit, global actions where exported in
ActionTemplateItem/erp5/portal_actions/action_id and not in
ActionTemplateItem/portal_types/portal_actions/action_id anymore. This change
restores the previous behaviour.



git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@35166 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 6c601e66
...@@ -2619,7 +2619,11 @@ class ActionTemplateItem(ObjectTemplateItem): ...@@ -2619,7 +2619,11 @@ class ActionTemplateItem(ObjectTemplateItem):
url = posixpath.split(url) url = posixpath.split(url)
obj = p.unrestrictedTraverse(url) obj = p.unrestrictedTraverse(url)
# normalize url # normalize url
url = obj.getPhysicalPath()[-2:] url = p.portal_url.getRelativeContentPath(obj)
if len(url) == 1:
# global actions are stored under 'portal_types', mostly for
# compatibility
url = 'portal_types', url[0]
action = self._getActionCopy(obj, context, value) action = self._getActionCopy(obj, context, value)
if action is None: if action is None:
if self.is_bt_for_diff: if self.is_bt_for_diff:
......
...@@ -6503,6 +6503,50 @@ class TestBusinessTemplate(ERP5TypeTestCase, LogInterceptor): ...@@ -6503,6 +6503,50 @@ class TestBusinessTemplate(ERP5TypeTestCase, LogInterceptor):
instance.setSourceReference('OK') instance.setSourceReference('OK')
self.assertEquals('OK', instance.getSourceReference()) self.assertEquals('OK', instance.getSourceReference())
def test_global_action(self):
# Tests that global actions are properly exported and reimported
self.portal.portal_actions.addAction(
id='test_global_action',
name='Test Global Action',
action='',
condition='',
permission='',
category='object_view')
action_idx = len(self.portal.portal_actions._actions)
bt = self.portal.portal_templates.newContent(
portal_type='Business Template',
title='test_bt',
template_action_path_list=(
'portal_actions | test_global_action',),)
self.stepTic()
bt.build()
self.stepTic()
export_dir = tempfile.mkdtemp()
try:
bt.export(path=export_dir, local=True)
self.stepTic()
# actions are exported in portal_types/ and then the id of the container
# tool
self.assertEquals(['portal_actions'],
[os.path.basename(f) for f in
glob.glob('%s/ActionTemplateItem/portal_types/*' % (export_dir, ))])
new_bt = self.portal.portal_templates.download(
url='file:/%s' % export_dir)
finally:
shutil.rmtree(export_dir)
# manually uninstall the action
self.portal.portal_actions.deleteActions(selections=[action_idx])
self.stepTic()
# install the business template and make sure the action is properly
# installed
new_bt.install()
self.stepTic()
self.assertNotEquals(None,
self.portal.portal_actions.getActionInfo('object_view/test_global_action'))
def test_suite(): def test_suite():
suite = unittest.TestSuite() suite = unittest.TestSuite()
......
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