Commit 7ce62c57 authored by Jérome Perrin's avatar Jérome Perrin

pdm: honor "preferred node category" in stock browser

make the node_category dialog pre-select the preferred node category
parent 89a94cec
......@@ -570,7 +570,7 @@
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>python:[(\'group_by_section\', 0), (\'group_by_node\', 1), (\'group_by_variation\', 1)]</string> </value>
<value> <string>python:[(\'node_category\', request.get(\'node_category\', preferences.getPreferredNodeCategory()))]</string> </value>
</item>
</dictionary>
</pickle>
......
<?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>testNodeCategoryPreference</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>
<head><title>Test stock browser with node category preference</title></head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<thead>
<tr><td rowspan="1" colspan="4">
Test stock browser with node category preference
</td></tr>
</thead>
<tbody tal:define="init_method string:PdmZuite_createDelivery?state=stopped;
set_node_category_preference python: True">
<!-- Setup {{{ -->
<tal:block metal:use-macro="here/PdmZuite_CommonTemplateForRenderjsUi/macros/init" />
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_listbox_loaded" />
<!-- Check destination -->
<tal:block tal:define="node_category python: 'erp5_pdm_ui_test_destination_site_title';
node_title string: erp5_pdm_ui_test_destination_node_title;
movement_count python: 1;
current_inventory python: 1.0;
available_inventory python: 1.0;
future_inventory python: 1.0;
">
<tal:block metal:use-macro="here/PdmZuite_checkStockBrowserForRenderjsUi/macros/check_inventory" />
</tal:block>
<tal:block metal:use-macro="here/PdmZuite_CommonTemplateForRenderjsUi/macros/check_links_for_stocks" />
<!-- Check the links in hardcoded way -->
<!-- TODO: If possible, move to macros -->
<tr>
<td>waitForElementPresent</td>
<td>//div[@data-gadget-scope='field_listbox']//table/tbody/tr[1]/td[1]/a</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>//div[@data-gadget-scope='field_listbox']//table/tbody/tr[1]/td[1]/a</td>
<td></td>
</tr>
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_listbox_loaded" />
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_content_loaded" />
<tal:block tal:define="pagination_configuration python: {'header': '(1)', 'footer': '1 Records'}">
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/check_listbox_pagination_text" />
</tal:block>
<tr>
<td>waitForElementPresent</td>
<td>//div[@data-gadget-scope='field_listbox']//table/tbody</td>
<td></td>
</tr>
<tr>
<td>verifyText</td>
<td>//div[@data-gadget-scope='field_listbox']//table/tbody/tr[1]/td[3]</td>
<td>erp5_pdm_ui_test_destination_node_title</td>
</tr>
<tal:block metal:use-macro="here/PdmZuite_CommonTemplateForRenderjsUi/macros/check_links" />
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_listbox_loaded" />
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/submit_dialog" />
<tr>
<td>assertElementPresent</td>
<td>//div[@data-gadget-scope='field_listbox']//table/tbody/tr[1]/td[5]/a</td>
<td></td>
</tr>
</tbody></table>
</body>
</html>
<!-- vim: syntax=html foldmethod=marker -->
\ No newline at end of file
<tal:block xmlns:tal="http://xml.zope.org/namespaces/tal"
xmlns:metal="http://xml.zope.org/namespaces/metal">
<tal:block metal:define-macro="init"
tal:define="resource_relative_url resource_relative_url | string:product_module/erp5_pdm_ui_test_product">
tal:define="resource_relative_url resource_relative_url | string:product_module/erp5_pdm_ui_test_product;
set_node_category_preference set_node_category_preference | python: False">
<tal:block metal:use-macro="here/Zuite_CommonTemplate/macros/init" />
<tr>
<td>open</td>
......@@ -27,7 +28,8 @@
<tr>
<td>open</td>
<td>${base_url}/PdmZuite_reset</td>
<td tal:condition="not: set_node_category_preference">${base_url}/PdmZuite_reset</td>
<td tal:condition="set_node_category_preference">${base_url}/PdmZuite_reset?set_node_category_preference:bool=True</td>
<td></td>
</tr>
<tr>
......
<tal:block xmlns:tal="http://xml.zope.org/namespaces/tal"
xmlns:metal="http://xml.zope.org/namespaces/metal">
<tal:block metal:define-macro="check_inventory" tal:define="base_url python: '/' + here.getPortalObject().getId()">
<tal:block
metal:define-macro="check_inventory"
tal:define="base_url python: '/' + here.getPortalObject().getId();
select_node_category select_node_category | python: True">
<tr>
<td colspan="3"><b>Select node category in dialog</b></td>
</tr>
<tr>
<td>select</td>
<td>//select[@name="field_your_node_category"]</td>
<td tal:content='node_category'></td>
</tr>
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/submit_dialog" />
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_content_loaded" />
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_listbox_loaded" />
<tal:block tal:condition="select_node_category">
<tr>
<td colspan="3"><b>Select node category in dialog</b></td>
</tr>
<tr>
<td>select</td>
<td>//select[@name="field_your_node_category"]</td>
<td tal:content='node_category'></td>
</tr>
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/submit_dialog" />
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_content_loaded" />
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_listbox_loaded" />
</tal:block>
<tal:block tal:condition="not: select_node_category">
<tr>
<td>assertSelected</td>
<td>//select[@name="field_your_node_category"]</td>
<td tal:content='node_category'></td>
</tr>
</tal:block>
<!-- Check inventory total records -->
<tal:block tal:define="pagination_configuration python: {'header': '(%s)' % movement_count, 'footer': '%s Records' % movement_count}">
......
<?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>node_category_preference</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>
<head><title>Test stock browser with node category preference</title></head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<thead>
<tr><td rowspan="1" colspan="4">
Test stock browser with node category preference
</td></tr>
</thead>
<tbody tal:define="init_method string:PdmZuite_createDelivery?state=stopped;
set_node_category_preference python: True">
<!-- Setup {{{ -->
<tal:block metal:use-macro="here/PdmZuite_CommonTemplate/macros/init" />
<!-- }}} -->
<!-- Check destination -->
<tal:block tal:define="node_category python: 'erp5_pdm_ui_test_destination_site_title';
select_node_category python:False;
movement_count python: 1;
current_inventory python: 1.0;
available_inventory python: 1.0;
future_inventory python: 1.0;
">
<tal:block metal:use-macro="here/PdmZuite_checkStockBrowser/macros/check_inventory" />
</tal:block>
</tbody></table>
</body>
</html>
<!-- vim: syntax=html foldmethod=marker -->
\ No newline at end of file
<tal:block xmlns:tal="http://xml.zope.org/namespaces/tal"
xmlns:metal="http://xml.zope.org/namespaces/metal">
<tal:block metal:define-macro="init">
<tal:block metal:define-macro="init"
tal:define="set_node_category_preference set_node_category_preference | python: False">
<tal:block metal:use-macro="here/Zuite_CommonTemplate/macros/init" />
<tr>
<td>setTimeout</td>
......@@ -31,7 +32,8 @@
<tr>
<td>open</td>
<td>${base_url}/PdmZuite_reset</td>
<td tal:condition="not: set_node_category_preference">${base_url}/PdmZuite_reset</td>
<td tal:condition="set_node_category_preference">${base_url}/PdmZuite_reset?set_node_category_preference:bool=True</td>
<td></td>
</tr>
<tr>
......
<tal:block xmlns:tal="http://xml.zope.org/namespaces/tal"
xmlns:metal="http://xml.zope.org/namespaces/metal">
<tal:block metal:define-macro="check_inventory" tal:define="base_url python: '/' + here.getPortalObject().getId()">
<!-- Select node category in dialog -->
<tr>
<td>select</td>
<td>//select[@name="field_your_node_category"]</td>
<td tal:content='node_category'></td>
</tr>
<tr>
<td>clickAndWait</td>
<td>Base_callDialogMethod:method</td>
<td></td>
</tr>
<tal:block
metal:define-macro="check_inventory"
tal:define="base_url python: '/' + here.getPortalObject().getId();
select_node_category select_node_category | python: True">
<tal:block tal:condition="select_node_category">
<!-- Select node category in dialog -->
<tr>
<td>select</td>
<td>//select[@name="field_your_node_category"]</td>
<td tal:content='node_category'></td>
</tr>
<tr>
<td>clickAndWait</td>
<td>Base_callDialogMethod:method</td>
<td></td>
</tr>
</tal:block>
<tal:block tal:condition="not: select_node_category">
<tr>
<td>assertSelected</td>
<td>//select[@name="field_your_node_category"]</td>
<td tal:content='node_category'></td>
</tr>
</tal:block>
<!-- Check inventory -->
<tr>
......@@ -56,17 +69,26 @@
<td></td>
</tr>
<!-- Select node category in dialog (again) -->
<tr>
<td>select</td>
<td>//select[@name="field_your_node_category"]</td>
<td tal:content='node_category'></td>
</tr>
<tr>
<td>clickAndWait</td>
<td>Base_callDialogMethod:method</td>
<td></td>
</tr>
<tal:block tal:condition="select_node_category">
<!-- Select node category in dialog (again) -->
<tr>
<td>select</td>
<td>//select[@name="field_your_node_category"]</td>
<td tal:content='node_category'></td>
</tr>
<tr>
<td>clickAndWait</td>
<td>Base_callDialogMethod:method</td>
<td></td>
</tr>
</tal:block>
<tal:block tal:condition="not: select_node_category">
<tr>
<td>assertSelected</td>
<td>//select[@name="field_your_node_category"]</td>
<td tal:content='node_category'></td>
</tr>
</tal:block>
</tal:block>
</tal:block>
</tal:block>
......
......@@ -48,6 +48,11 @@ for site_id, site_title in ((source_site_id, source_site_title),
title=site_title
)
# configure preference
portal.portal_preferences.getActivePreference().setPreferredNodeCategory(
'site/' + destination_site_id if set_node_category_preference else None
)
# Create nodes
for node_id, node_title, site_url in ((source_node_id, source_node_title, source_site_id),
(destination_node_id, destination_node_title, destination_site_id)):
......
......@@ -50,7 +50,7 @@
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
<value> <string>set_node_category_preference=False</string> </value>
</item>
<item>
<key> <string>id</string> </key>
......
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