Commit 1f7ff604 authored by Ayush Tiwari's avatar Ayush Tiwari

Diff Tool: Redirect to the context in case there is selection of more or less...

Diff Tool: Redirect to the context in case there is selection of more or less than 2 objects in a module for diff

Also, update portal action regarding the module selection and add tests
parent 0675f6c9
<?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>testDiffActionOnModuleWithMoreThanTwoSelection</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 Generic Search Dialog</title>
</head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<thead>
<tr><td rowspan="1" colspan="3">Test Portal Diff<tal:block metal:use-macro="here/Zuite_CommonTemplate/macros/expected_failure_for_anonymous_selection" /></td></tr>
</thead><tbody>
<tal:block metal:use-macro="here/PTZuite_CommonTemplate/macros/init" />
<tr>
<td>open</td>
<td tal:content="string:${here/portal_url}/bar_module/FooModule_createObjects?start:int=1&num:int=1"/>
<td></td>
</tr>
<tr>
<td>assertTextPresent</td>
<td>Created Successfully</td>
<td></td>
</tr>
<tr>
<td>open</td>
<td tal:content="string:${here/portal_url}/bar_module/FooModule_createObjects?start:int=2&num:int=1"/>
<td></td>
</tr>
<tr>
<td>assertTextPresent</td>
<td>Created Successfully</td>
<td></td>
</tr>
<tr>
<td>open</td>
<td tal:content="string:${here/portal_url}/bar_module/FooModule_createObjects?start:int=3&num:int=1"/>
<td></td>
</tr>
<tr>
<td>assertTextPresent</td>
<td>Created Successfully</td>
<td></td>
</tr>
<tr>
<td>open</td>
<td>${base_url}/bar_module/Zuite_waitForActivities</td>
<td></td>
</tr>
<tr>
<td>open</td>
<td>${base_url}/bar_module/view</td>
<td></td>
</tr>
<tr>
<td>clickAndWait</td>
<td>Folder_show:method</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>//*[@class="listbox-data-line-0 DataA"]//input[@type="checkbox"]</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>//*[@class="listbox-data-line-1 DataB"]//input[@type="checkbox"]</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>//*[@class="listbox-data-line-2 DataA"]//input[@type="checkbox"]</td>
<td></td>
</tr>
<!-- Click on the action to check the diff between the 2 objects -->
<tr>
<td>selectAndWait</td>
<td>select_action</td>
<td>Diff Module Objects</td>
</tr>
<tr>
<td>assertElementPresent</td>
<td>//*[@class="listbox-data-line-0 DataA"]</td>
<td></td>
</tr>
<tr>
<td>assertElementPresent</td>
<td>//*[@class="listbox-data-line-1 DataB"]</td>
<td></td>
</tr>
<tr>
<td>assertElementPresent</td>
<td>//*[@class="listbox-data-line-2 DataA"]</td>
<td></td>
</tr>
<tr>
<td>assertTextPresent</td>
<td>This action can only compare exactly 2 objects.</td>
<td></td>
</tr>
<tr>
<td>assertPortalStatusMessage</td>
<td>This action can only compare exactly 2 objects.</td>
<td></td>
</tr>
</body>
</html>
\ No newline at end of file
......@@ -65,7 +65,7 @@
<dictionary>
<item>
<key> <string>text</string> </key>
<value> <string>python: object.absolute_url() + \'/ERP5Site_viewDiffTwoObjectDialog\'</string> </value>
<value> <string>python: object.absolute_url() + \'/Base_viewDiffDialogForModuleSelection\'</string> </value>
</item>
</dictionary>
</pickle>
......
......@@ -30,9 +30,6 @@ if first_path is None and second_path is None:
# create diff.
if list_selection_name is not None:
selected_obj_list = portal.portal_selections.getSelectionCheckedValueList(selection_name=list_selection_name)
# Check if the number of selected object is 2 only. otherwise raise an error
if len(selected_obj_list) != 2:
raise ValueError('Please select accurately 2 objects.')
object_revision_list.extend(selected_obj_list)
else:
# Return an empty list here. This would be the case when we first access
......
"""
This script redirects to Diff Tool Dialog. It is used for the case where we
select 2 objects from a Module and try to get the diff between them.
In case there is selection of more or less than 2 objects, it simply redirects
back to the module with a portal message.
"""
request = context.REQUEST
portal = context.getPortalObject()
list_selection_name = request.get('list_selection_name', None)
# In case the list_selection_name is there, it can be the case of selection
# from the module
if list_selection_name is not None:
selected_obj_list = portal.portal_selections.getSelectionCheckedValueList(selection_name=list_selection_name)
# Check if the number of selected object is 2 only. otherwise redirect back to
# context with a portal message.
if len(selected_obj_list) != 2:
message = context.Base_translateString("This action can only compare exactly 2 objects.")
return context.Base_redirect('view', keep_items={'portal_status_message': message})
else:
# Keep the `list_selection_name` in keep_items as we will be needing it
# while displaying the paths of the selected objects.
return context.Base_redirect('ERP5Site_viewDiffTwoObjectDialog',
keep_items={'list_selection_name': list_selection_name})
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<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_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<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>_params</string> </key>
<value> <string>**kw</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Base_viewDiffDialogForModuleSelection</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -158,6 +158,8 @@ portal_actions | catalog_tool
portal_actions | category_tool
portal_actions | component_tool
portal_actions | create_module
portal_actions | diff_multiple_object_action
portal_actions | diff_object_action
portal_actions | history
portal_actions | list_ui
portal_actions | make_template
......
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