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 e768f4a06e17c4cddc7f0f99239a3f95599adecd..ff1265fbea10206bf565ba4830dd1d1d32186079 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/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 4b2f4bb5a412e7211e23b28334db2b4e4318085d..052961a58891b6d5b7308010afa48c05607c12db 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))) 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 352787e4df34e982f169aef9a32d563a834d42e4..ffd7ad568d48394904b67270e6bef54377e848cc 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 - + diff --git a/product/ERP5/tests/testZODBHistory.py b/product/ERP5/tests/testZODBHistory.py index 30f4c1a1629ce850749a66de4ff7af3d8b1fa6bc..2e9b129a332e77a8e640a5cd737012461a9e3997 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 @@ -122,7 +123,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. """ @@ -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()