[Erp5-report] r35166 jerome - in /erp5/trunk/products/ERP5: Document/ tests/

nobody at svn.erp5.org nobody at svn.erp5.org
Tue May 11 13:35:57 CEST 2010


Author: jerome
Date: Tue May 11 13:35:53 2010
New Revision: 35166

URL: http://svn.erp5.org?rev=35166&view=rev
Log:
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.


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=35166&r1=35165&r2=35166&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Document/BusinessTemplate.py [utf8] (original)
+++ erp5/trunk/products/ERP5/Document/BusinessTemplate.py [utf8] Tue May 11 13:35:53 2010
@@ -2619,7 +2619,11 @@
       url = posixpath.split(url)
       obj = p.unrestrictedTraverse(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)
       if action is None:
         if self.is_bt_for_diff:

Modified: erp5/trunk/products/ERP5/tests/testBusinessTemplate.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/tests/testBusinessTemplate.py?rev=35166&r1=35165&r2=35166&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/tests/testBusinessTemplate.py [utf8] (original)
+++ erp5/trunk/products/ERP5/tests/testBusinessTemplate.py [utf8] Tue May 11 13:35:53 2010
@@ -6503,6 +6503,50 @@
     instance.setSourceReference('OK')
     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():
   suite = unittest.TestSuite()




More information about the Erp5-report mailing list