Commit 400c58e9 authored by Xiaowu Zhang's avatar Xiaowu Zhang

erp5_*: add ZODB History report instead of using links in History tabs

parent 241f7b53
...@@ -243,6 +243,7 @@ class TestERP5Core(ERP5TypeTestCase, ZopeTestCase.Functional): ...@@ -243,6 +243,7 @@ class TestERP5Core(ERP5TypeTestCase, ZopeTestCase.Functional):
'title': 'View Historical Diff'}], 'title': 'View Historical Diff'}],
'object_jio_action': [{'id': 'post_query', 'title': 'Post a Query'}], 'object_jio_action': [{'id': 'post_query', 'title': 'Post a Query'}],
'object_jio_jump': [{'id': 'jump_query', 'title': 'Queries'}], 'object_jio_jump': [{'id': 'jump_query', 'title': 'Queries'}],
'object_jio_report': [{'id': 'zodb_history', 'title': 'ZODB History'}],
'object_jump': [{'id': 'jump_related_object', 'title': 'Related Objects'}], 'object_jump': [{'id': 'jump_related_object', 'title': 'Related Objects'}],
'object_search': [{'title': 'Search', 'id': 'search'}], 'object_search': [{'title': 'Search', 'id': 'search'}],
'object_sort': [{'title': 'Sort', 'id': 'sort_on'}], 'object_sort': [{'title': 'Sort', 'id': 'sort_on'}],
......
...@@ -117,17 +117,15 @@ class TestZODBHistory(ERP5TypeTestCase): ...@@ -117,17 +117,15 @@ class TestZODBHistory(ERP5TypeTestCase):
""" """
self.loginByUserName('tatuya') self.loginByUserName('tatuya')
document = self.addOrganisation('document') document = self.addOrganisation('document')
report_id_list = [x['id'] for x in self.portal.portal_actions.listFilteredActionsFor(document).get('object_jio_report',[])]
# by default, users have a link to view ZODB history in history tab self.assertIn('zodb_history', report_id_list)
self.assertIn(
'your_zodb_history',
[field.getId() for field in document.Base_viewHistory.get_fields()])
# when user does not have "View History" permission, the link is not displayed # when user does not have "View History" permission, the link is not displayed
document.manage_permission('View History', [], 0) document.manage_permission('View History', [], 0)
self.assertNotIn( report_id_list = [x['id'] for x in self.portal.portal_actions.listFilteredActionsFor(document).get('object_jio_report',[])]
'your_zodb_history',
[field.getId() for field in document.Base_viewHistory.get_fields()]) self.assertNotIn('zodb_history', report_id_list)
# accessing the form directly is not allowed either # accessing the form directly is not allowed either
from zExceptions import Unauthorized from zExceptions import Unauthorized
......
...@@ -1187,10 +1187,6 @@ class TestERP5Document_getHateoas_mode_traverse(ERP5HALJSONStyleSkinsMixin): ...@@ -1187,10 +1187,6 @@ class TestERP5Document_getHateoas_mode_traverse(ERP5HALJSONStyleSkinsMixin):
self.assertEqual(result_dict['_embedded']['_view']['form_id']['required'], 1) self.assertEqual(result_dict['_embedded']['_view']['form_id']['required'], 1)
self.assertEqual(result_dict['_embedded']['_view']['form_id']['type'], 'StringField') self.assertEqual(result_dict['_embedded']['_view']['form_id']['type'], 'StringField')
self.assertEqual(result_dict['_embedded']['_view']['your_zodb_history']['title'], 'View ZODB History')
self.assertEqual(result_dict['_embedded']['_view']['your_zodb_history']['key'], 'field_your_zodb_history')
self.assertEqual(result_dict['_embedded']['_view']['your_zodb_history']['type'], 'LinkField')
# Check embedded report section rendering # Check embedded report section rendering
self.assertEqual(result_dict['_embedded']['_view']['report_section_list'][1]['form_id']['default'], 'Base_viewWorkflowHistory') self.assertEqual(result_dict['_embedded']['_view']['report_section_list'][1]['form_id']['default'], 'Base_viewWorkflowHistory')
self.assertEqual(result_dict['_embedded']['_view']['report_section_list'][1]['form_id']['editable'], 0) self.assertEqual(result_dict['_embedded']['_view']['report_section_list'][1]['form_id']['editable'], 0)
...@@ -1205,14 +1201,6 @@ class TestERP5Document_getHateoas_mode_traverse(ERP5HALJSONStyleSkinsMixin): ...@@ -1205,14 +1201,6 @@ class TestERP5Document_getHateoas_mode_traverse(ERP5HALJSONStyleSkinsMixin):
self.assertEqual(result_dict['_embedded']['_view']['report_section_list'][1]['_links']['form_definition']['href'], 'urn:jio:get:portal_skins/erp5_core/Base_viewWorkflowHistory') self.assertEqual(result_dict['_embedded']['_view']['report_section_list'][1]['_links']['form_definition']['href'], 'urn:jio:get:portal_skins/erp5_core/Base_viewWorkflowHistory')
self.assertEqual(result_dict['_embedded']['_view']['report_section_list'][1]['_links']['form_definition']['name'], 'Base_viewWorkflowHistory') self.assertEqual(result_dict['_embedded']['_view']['report_section_list'][1]['_links']['form_definition']['name'], 'Base_viewWorkflowHistory')
self.assertEqual(
result_dict['_embedded']['_view']['_embedded']['form_definition']['group_list'][0][0],
'center'
)
self.assertEqual(
result_dict['_embedded']['_view']['_embedded']['form_definition']['group_list'][0][1][0],
['your_zodb_history', {'meta_type': 'LinkField'}]
)
self.assertEqual( self.assertEqual(
result_dict['_embedded']['_view']['_embedded']['form_definition']['pt'], result_dict['_embedded']['_view']['_embedded']['form_definition']['pt'],
'report_view' 'report_view'
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ZopePageTemplate" module="Products.PageTemplates.ZopePageTemplate"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>text/html</string> </value>
</item>
<item>
<key> <string>expand</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>testZODBHistory</string> </value>
</item>
<item>
<key> <string>output_encoding</string> </key>
<value> <string>utf-8</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <unicode></unicode> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<html xmlns:tal="http://xml.zope.org/namespaces/tal"
xmlns:metal="http://xml.zope.org/namespaces/metal">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Test ZODB History</title>
</head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<thead>
<tr><td rowspan="1" colspan="3">Test ZODB History</td></tr>
</thead><tbody>
<tr>
<td>store</td>
<td tal:content="python:here.getPortalObject().absolute_url()">http://example.com/erp5</td>
<td>base_url</td>
</tr>
<tr>
<td>open</td>
<td>${base_url}/bar_module/ListBoxZuite_reset</td>
<td></td>
</tr>
<tr>
<td>assertTextPresent</td>
<td>Reset Successfully.</td>
<td></td>
</tr>
<tr>
<td>openAndWait</td>
<td>${base_url}/bar_module/Zuite_waitForActivities</td>
<td></td>
</tr>
<tr>
<td>assertTextPresent</td>
<td>Done.</td>
<td></td>
</tr>
<tr>
<td>open</td>
<td>${base_url}/bar_module/FooModule_createObjects?portal_type=Bar&amp;num:int=1</td>
<td></td>
</tr>
<tr>
<td>open</td>
<td>${base_url}/bar_module/0</td>
<td></td>
</tr>
<tr>
<td>type</td>
<td>field_my_title</td>
<td>Version 1</td>
</tr>
<tr>
<td>clickAndWait</td>
<td>Base_edit:method</td>
<td></td>
</tr>
<tr>
<td>type</td>
<td>field_my_title</td>
<td>Version 2</td>
</tr>
<tr>
<td>clickAndWait</td>
<td>Base_edit:method</td>
<td></td>
</tr>
<tr>
<td>type</td>
<td>field_my_title</td>
<td>Version 3</td>
</tr>
<tr>
<td>clickAndWait</td>
<td>Base_edit:method</td>
<td></td>
</tr>
<tr>
<td>clickAndWait</td>
<td>//button[@class="report"]</td>
<td></td>
</tr>
<tr>
<td>verifyText</td>
<td>//span[@class="listbox-current-page-total-number"]</td>
<td>4 records</td> <!-- Creation + edited 3 times -->
</tr>
<tr>
<td>verifyTextPresent</td>
<td>ZODB History</td>
<td></td>
</tr>
<tr>
<td>verifyTextPresent</td>
<td>title: Version 1</td>
<td></td>
</tr>
<tr>
<td>verifyTextPresent</td>
<td>title: Version 2</td>
<td></td>
</tr>
<tr>
<td>verifyTextPresent</td>
<td>title: Version 3</td>
<td></td>
</tr>
</tbody></table>
</body>
</html>
\ No newline at end of file
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ZopePageTemplate" module="Products.PageTemplates.ZopePageTemplate"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>text/html</string> </value>
</item>
<item>
<key> <string>expand</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>testZODBHistoryInExportPage</string> </value>
</item>
<item>
<key> <string>output_encoding</string> </key>
<value> <string>utf-8</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <unicode></unicode> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<html xmlns:tal="http://xml.zope.org/namespaces/tal"
xmlns:metal="http://xml.zope.org/namespaces/metal">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Test ZODB History</title>
</head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<thead>
<tr><td rowspan="1" colspan="3">Test ZODB History</td></tr>
</thead><tbody>
<tal:block metal:use-macro="here/PTZuite_CommonTemplate/macros/init" />
<tr>
<td>open</td>
<td>${base_url}/web_site_module/renderjs_runner/#/foo_module/1?page=export</td>
<td></td>
</tr>
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_app_loaded" />
<tr>
<td>assertElementPresent</td>
<td>//div[@data-gadget-url='${base_url}/web_site_module/renderjs_runner/gadget_erp5_page_export.html']</td>
<td></td>
</tr>
<tr>
<td>verifyTextPresent</td>
<td>ZODB History</td>
<td></td>
</tr>
<tal:block tal:define="click_configuration python: {'text': 'ZODB History'}">
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/click_on_page_link" />
</tal:block>
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_content_loaded" />
<tr>
<td>verifyElementPresent</td>
<td>//h1[contains(text(), 'ZODB History')]</td>
<td></td>
</tr>
</tbody></table>
</body>
</html>
\ No newline at end of file
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ActionInformation" module="Products.CMFCore.ActionInformation"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>action</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>category</string> </key>
<value> <string>object_jio_report</string> </value>
</item>
<item>
<key> <string>condition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>icon</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>zodb_history</string> </value>
</item>
<item>
<key> <string>permissions</string> </key>
<value>
<tuple>
<string>View History</string>
</tuple>
</value>
</item>
<item>
<key> <string>priority</string> </key>
<value> <float>99.0</float> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>ZODB History</string> </value>
</item>
<item>
<key> <string>visible</string> </key>
<value> <int>1</int> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="Expression" module="Products.CMFCore.Expression"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>text</string> </key>
<value> <string>string:${object_url}/Base_viewZODBHistory</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -74,9 +74,7 @@ ...@@ -74,9 +74,7 @@
<item> <item>
<key> <string>center</string> </key> <key> <string>center</string> </key>
<value> <value>
<list> <list/>
<string>your_zodb_history</string>
</list>
</value> </value>
</item> </item>
<item> <item>
......
...@@ -82,9 +82,7 @@ ...@@ -82,9 +82,7 @@
<item> <item>
<key> <string>center</string> </key> <key> <string>center</string> </key>
<value> <value>
<list> <list/>
<string>your_workflow_history</string>
</list>
</value> </value>
</item> </item>
<item> <item>
......
...@@ -207,6 +207,7 @@ portal_actions | sort_on ...@@ -207,6 +207,7 @@ portal_actions | sort_on
portal_actions | types_tool portal_actions | types_tool
portal_actions | view_historical_comparison portal_actions | view_historical_comparison
portal_actions | view_historical_diff portal_actions | view_historical_diff
portal_actions | zodb_history
portal_membership | login portal_membership | login
portal_membership | logout portal_membership | logout
portal_membership | preferences portal_membership | preferences
......
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