Commit 66a2c883 authored by Romain Courteaud's avatar Romain Courteaud

[erp5_core/xhtml_style] Handle xhtml only view action

parent 71a3f9af
<?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>categories</string> </key>
<value>
<tuple>
<string>action_type/object_onlyxhtml_view</string>
</tuple>
</value>
</item>
<item>
<key> <string>category</string> </key>
<value> <string>object_onlyxhtml_view</string> </value>
</item>
<item>
<key> <string>condition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>Visible only in XHTML style</string> </value>
</item>
<item>
<key> <string>icon</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>view_onlyxhtml</string> </value>
</item>
<item>
<key> <string>permissions</string> </key>
<value>
<tuple>
<string>View</string>
</tuple>
</value>
</item>
<item>
<key> <string>priority</string> </key>
<value> <float>2.0</float> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>View Only XHTML</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_viewMetadata</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?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>testTabOnlyXHTML</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 Add Object</title>
</head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<thead>
<tr><td rowspan="1" colspan="3">Test View Tab only for ERP5JS</td></tr>
</thead><tbody>
<tal:block metal:use-macro="here/PTZuite_CommonTemplate/macros/init" />
<!-- First, create the document -->
<tr>
<td>open</td>
<td>${base_url}/foo_module/FooModule_createObjects?portal_type=Foo&amp;num:int=1</td>
<td></td>
</tr>
<tr>
<td>open</td>
<td>${base_url}/foo_module/0</td>
<td></td>
</tr>
<tr>
<td>assertElementPresent</td>
<td>//*[@class="actions"]//ul/li[2]//span[text()="View Only XHTML"]</td>
<td></td>
</tr>
</table>
</body>
</html>
\ No newline at end of file
...@@ -41,6 +41,7 @@ Foo | view_hidden_positive_only_quantity ...@@ -41,6 +41,7 @@ Foo | view_hidden_positive_only_quantity
Foo | view_listbox Foo | view_listbox
Foo | view_multiple_listbox Foo | view_multiple_listbox
Foo | view_onlyjio Foo | view_onlyjio
Foo | view_onlyxhtml
Foo | view_planning Foo | view_planning
Foo | view_print_dialog Foo | view_print_dialog
Foo | view_printout_form Foo | view_printout_form
......
<?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>testPageTabViewsOnlyXHTMLLinkList</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 Page Front</title>
</head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<thead>
<tr><td rowspan="1" colspan="3">Test Page Tab Link List</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=tab</td>
<td></td>
</tr>
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_app_loaded" />
<!-- Wait for gadget to be loaded -->
<tr>
<td>assertElementPresent</td>
<td>//div[@data-gadget-url='${base_url}/web_site_module/renderjs_runner/gadget_erp5_page_tab.html']</td>
<td></td>
</tr>
<!-- Generate links to parents -->
<tr>
<td>assertElementNotPresent</td>
<td>//div[@data-gadget-scope='m']//a[text()='View Only XHTML' and contains(@href, '#!display_with_history') and contains(@href, 'u.page=')]</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="Category" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_Add_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Add_portal_folders_Permission</string> </key>
<value>
<tuple>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Copy_or_Move_Permission</string> </key>
<value>
<tuple>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Delete_objects_Permission</string> </key>
<value>
<tuple>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Modify_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>action_type/object_onlyjio_action</string>
</tuple>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>object_onlyxhtml_view</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Category</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>object_onlyxhtml_view</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -10,25 +10,34 @@ def filterDuplicateActions(actions): ...@@ -10,25 +10,34 @@ def filterDuplicateActions(actions):
new_actions = {} new_actions = {}
for action_category, action_list in actions.items(): for action_category, action_list in actions.items():
existing_actions = set() if action_category == 'object_onlyxhtml_view':
new_actions[action_category] = [] action_category = 'object_view'
new_actions.setdefault(action_category, [])
existing_actions = set([x['id'] for x in new_actions[action_category]])
keep_action = new_actions[action_category].append keep_action = new_actions[action_category].append
for action in action_list: for action in action_list:
if action['id'] not in existing_actions: if action['id'] not in existing_actions:
existing_actions.add(action['id']) existing_actions.add(action['id'])
keep_action(action) keep_action(action)
if (action_category == 'object_view'):
new_actions[action_category].sort(key=lambda x: x.get('priority', 1.0))
return new_actions return new_actions
def hasDuplicateActions(portal_type, user_name): def hasDuplicateActions(portal_type, user_name):
# Compare the count of action categories and actions
# Give every category a amount of 1000, as
# 'object_onlyxhtml_view' is transformed into 'object_view'
len_actions = 0 len_actions = 0
len_filtered_actions = 0 len_filtered_actions = 0
for cat in actions.values(): for cat in actions.values():
len_actions += len(cat) len_actions += 1000 + len(cat)
filtered_actions = filterDuplicateActions(actions) filtered_actions = filterDuplicateActions(actions)
for cat in filtered_actions.values(): for cat in filtered_actions.values():
len_filtered_actions += len(cat) len_filtered_actions += 1000 + len(cat)
return len_actions != len_filtered_actions return len_actions != len_filtered_actions
......
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