From 88719ec6df3d0059650338e9d355166e6aca054c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9rome=20Perrin?= Date: Tue, 28 Nov 2017 10:01:50 +0000 Subject: [PATCH 1/4] core: support `ignore_layout` request argument in View ZODB History Link Otherwise we cannot use this feature on a website/websection using a different skin selection. --- .../erp5_core/Base_viewHistory/your_zodb_history.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_viewHistory/your_zodb_history.xml b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_viewHistory/your_zodb_history.xml index 4b2f4bb5a41..052961a5889 100644 --- a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_viewHistory/your_zodb_history.xml +++ b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_viewHistory/your_zodb_history.xml @@ -313,7 +313,7 @@ _text - string:${here/absolute_url}/Base_viewZODBHistory + python:\'{}/Base_viewZODBHistory?{}\'.format(context.absolute_url(), modules[\'ZTUtils\'].make_query(ignore_layout=request.get(\'ignore_layout\', 0))) -- 2.30.9 From c0203466a742b09ea3a28610c2d7e96f585e5093 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9rome=20Perrin?= Date: Tue, 28 Nov 2017 10:20:58 +0000 Subject: [PATCH 2/4] test: fix wrongly named test method --- product/ERP5/tests/testZODBHistory.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/product/ERP5/tests/testZODBHistory.py b/product/ERP5/tests/testZODBHistory.py index 30f4c1a1629..d438cde41ba 100644 --- a/product/ERP5/tests/testZODBHistory.py +++ b/product/ERP5/tests/testZODBHistory.py @@ -122,7 +122,7 @@ class TestZODBHistory(ERP5TypeTestCase): # should be: create(1) + edit(60) = 61 self.assertEqual(len(history_list), 61) - def test_testZODBHistorySecurity(self): + def test_ZODBHistorySecurity(self): """ Make sure ZODB History is not available when user does not have "View History" permission. """ -- 2.30.9 From 1b2d476628ff9ef0f0b61de028e2c37d7eeb8bd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9rome=20Perrin?= Date: Tue, 28 Nov 2017 10:22:16 +0000 Subject: [PATCH 3/4] core: support binary data in ZODB History View It was failing decoding unicode --- .../erp5_core/Base_getZODBHistoryList.py | 10 ++++++- product/ERP5/tests/testZODBHistory.py | 26 +++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_getZODBHistoryList.py b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_getZODBHistoryList.py index e768f4a06e1..ff1265fbea1 100644 --- a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_getZODBHistoryList.py +++ b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_getZODBHistoryList.py @@ -8,7 +8,15 @@ if not getSecurityManager().getUser().has_permission('View History', context): raise Unauthorized() def beautifyChange(change_dict): - return ["%s:%s" % (k,change_dict[k]) for k in sorted(change_dict.keys())] + change_list = [] + for property_name, property_value in sorted(change_dict.items()): + if isinstance(property_value, basestring): + try: + unicode(property_value, 'utf-8') + except UnicodeDecodeError: + property_value = '(binary)' + change_list.append('%s:%s' % (property_name, property_value)) + return change_list try: history_size = portal.portal_preferences.getPreferredHtmlStyleZodbHistorySize() diff --git a/product/ERP5/tests/testZODBHistory.py b/product/ERP5/tests/testZODBHistory.py index d438cde41ba..2e9b129a332 100644 --- a/product/ERP5/tests/testZODBHistory.py +++ b/product/ERP5/tests/testZODBHistory.py @@ -28,6 +28,7 @@ ############################################################################## import unittest +import os from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase @@ -144,6 +145,31 @@ class TestZODBHistory(ERP5TypeTestCase): from zExceptions import Unauthorized self.assertRaises(Unauthorized, document.Base_viewZODBHistory) + def test_ZODBHistoryBinaryData(self): + """ + Make sure ZODB History view works with binary content + """ + self.loginByUserName('tatuya') + document = self.addOrganisation(self.id()).newContent( + portal_type='Embedded File') + + document.setFile( + open(os.path.join( + os.path.dirname(__file__), + 'test_data', + 'images', + 'erp5_logo.png'))) + document.setTitle("ロゴ") + self.commit() + + # no encoding error + document.Base_viewZODBHistory() + + change, = document.Base_getZODBHistoryList() + self.assertIn('data:(binary)', change.getProperty('changes')) + self.assertIn('content_type:image/png', change.getProperty('changes')) + self.assertIn('title:ロゴ', change.getProperty('changes')) + def test_suite(): suite = unittest.TestSuite() -- 2.30.9 From 084be9241275ecafe183a1c0334d18a9f6bb680c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9rome=20Perrin?= Date: Tue, 28 Nov 2017 10:34:39 +0000 Subject: [PATCH 4/4] core: move your_workflow_history to center group The field needs to be in center group to comply with https://www.erp5.com/documentation/developer/guideline/module/erp5-Guideline.Module.Creation/#listbox-only-tabs-should-have-a-read-only-title-in-center-group --- .../portal_skins/erp5_core/Base_viewZODBHistory.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_viewZODBHistory.xml b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_viewZODBHistory.xml index 352787e4df3..ffd7ad568d4 100644 --- a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_viewZODBHistory.xml +++ b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_viewZODBHistory.xml @@ -82,7 +82,9 @@ center - + + your_workflow_history + @@ -96,9 +98,7 @@ left - - your_workflow_history - + -- 2.30.9