Commit 626b75c1 authored by Jérome Perrin's avatar Jérome Perrin

Small fixes to ZODB history tab

Assorted fixes for minor issues with ZODB History tab:

1. When viewing history of a website or websection in the "backoffice" interface, clicking on *View ZODB History* does not keep the `ignore_layout:int=1` request parameter that forces displaying the forms in the *View* skin selection.
2. Fix using ZODB history for documents with binary properties, such as `data` property on images and files. Instead of failing with unicode error, just display "(binary)". 
3. Put the link field in center group, forms with only fields in left group and nothing in right group have a border only on the left side. ( this is  https://www.erp5.com/documentation/developer/guideline/module/erp5-Guideline.Module.Creation/#listbox-only-tabs-should-have-a-read-only-title-in-center-group )

see before:
![before__1_](/uploads/eaafe271228e960f58b7b928cb517ac9/before__1_.png)

and after:
![Screenshot_2017-11-28_at_19.32.09](/uploads/bdd0adcc80b138dca7ddcb45b2ff184a/Screenshot_2017-11-28_at_19.32.09.png)



/reviewed-on !512
parents 79da3453 084be924
Pipeline #7283 passed with stage
in 0 seconds
......@@ -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()
......
......@@ -313,7 +313,7 @@
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>string:${here/absolute_url}/Base_viewZODBHistory</string> </value>
<value> <string>python:\'{}/Base_viewZODBHistory?{}\'.format(context.absolute_url(), modules[\'ZTUtils\'].make_query(ignore_layout=request.get(\'ignore_layout\', 0)))</string> </value>
</item>
</dictionary>
</pickle>
......
......@@ -82,7 +82,9 @@
<item>
<key> <string>center</string> </key>
<value>
<list/>
<list>
<string>your_workflow_history</string>
</list>
</value>
</item>
<item>
......@@ -96,9 +98,7 @@
<item>
<key> <string>left</string> </key>
<value>
<list>
<string>your_workflow_history</string>
</list>
<list/>
</value>
</item>
<item>
......
......@@ -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()
......
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