Commit bfd0d733 authored by Tomáš Peterka's avatar Tomáš Peterka Committed by Tomáš Peterka

[hal_json] Introduce hard limit on number of documents in one action

parent 0e2ed43f
......@@ -205,6 +205,27 @@ if len(listbox_id_list):
kw.update(**extra_param)
kw.update(keep_items=extra_param) # better backward compatibility
# early-stop if user selected all or too many documents
if len(extra_param.get("uids", ())) >= 1000 or extra_param.get("query", MARKER) == "":
if dialog_method == update_method:
pass # do not interrupt on UPDATE
elif extra_param.get("basedialog_force_submit", 0) == 0:
extra_param["basedialog_force_submit"] = 1
if len(extra_param.get("uids", ())) >= 1000:
translated_message=translate("Too many documents selected! Submit again to proceed with the first 1000 or Cancel and narrow down your search.")
else:
translated_message=translate("All documents are selected! Submit again to proceed or Cancel and narrow down your search.")
return context.Base_renderForm(
dialog_id,
message=translated_message,
level=WARNING,
keep_items=extra_param,
form_data=form_data)
elif len(extra_param.get("uids", ())) >= 1000:
# no force-submit and no update so we cut the UIDS
kw['uids'] = extra_param['uids'][:1000]
del extra_param['uids'] # remove UIDS from the extra_param to force re-computation
# if dialog_category is object_search, then edit the selection
if dialog_category == "object_search" :
portal.portal_selections.setSelectionParamsFor(kw['selection_name'], kw)
......
<?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>testMassWorkflowTransitionOnLimit</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 RenderJS UI Module Action Change State</title>
</head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<thead>
<tr><th rowspan="1" colspan="3">Test RenderJS UI Module Action Change State</th></tr>
</thead><tbody>
<tal:block metal:use-macro="here/Zuite_CommonTemplate/macros/init" />
<!-- Clean Up -->
<tr><td>open</td>
<td>${base_url}/foo_module/ListBoxZuite_reset</td><td></td></tr>
<tr><td>assertTextPresent</td>
<td>Reset Successfully.</td><td></td></tr>
<!-- Shortcut for full renderjs url -->
<tr><td>store</td>
<td>${base_url}/web_site_module/renderjs_runner</td>
<td>renderjs_url</td></tr>
<tr><th colspan="3">Create Foo objects with distinguishible titles (Title 1%, Title 2%)</th></tr>
<tr><td>open</td>
<td>${base_url}/foo_module/FooModule_createObjects?start:int=1000&amp;num:int=400</td><td></td></tr>
<tr><td>assertTextPresent</td>
<td>Created Successfully.</td><td></td></tr>
<tr><td>open</td>
<td>${base_url}/foo_module/FooModule_createObjects?start:int=2000&amp;num:int=400</td><td></td></tr>
<tr><td>assertTextPresent</td>
<td>Created Successfully.</td><td></td></tr>
<tr><td>open</td>
<td>${base_url}/foo_module/FooModule_createObjects?start:int=3000&amp;num:int=400</td><td></td></tr>
<tr><td>assertTextPresent</td>
<td>Created Successfully.</td><td></td></tr>
<tal:block metal:use-macro="here/Zuite_CommonTemplate/macros/wait_for_activities" />
<tr><td>open</td>
<td>${base_url}/FooModule_viewFooList/listbox/ListBox_setPropertyList?field_columns=id%7CID%0Atitle%7CTitle%0Asimulation_state%7CState&field_lines=3</td><td></td></tr>
<tr><td>assertTextPresent</td>
<td>Set Successfully.</td><td></td></tr>
<tr><td>open</td>
<td>${renderjs_url}/#/foo_module</td><td></td></tr>
<tr><td>waitForElementPresent</td>
<td>//div[@data-role="header"]//a[@data-i18n="Actions"]</td><td></td></tr>
<tr><td>click</td>
<td>//div[@data-role="header"]//a[@data-i18n="Actions"]</td><td></td></tr>
<tr><td>waitForElementPresent</td>
<td>//ul[@data-role="listview"]//a[@data-i18n="Change State"]</td><td></td></tr>
<tr><td>click</td>
<td>//ul[@data-role="listview"]//a[@data-i18n="Change State"]</td><td></td></tr>
<tal:block tal:define="pagination_configuration python: {'header': '(1 - 3 / 1200)', 'footer': 'Records 1 - 3 / 1200'}">
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/check_listbox_pagination_text" />
</tal:block>
<tr><td>waitForElementPresent</td>
<td>//select[@name="field_workflow_action"]</td><td></td></tr>
<tr><td>select</td>
<td>//select[@name="field_workflow_action"]</td>
<td>value=validate_action</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 tal:define="notification_configuration python: {'class': 'error', 'text': 'Too many documents selected! Submit again to proceed with the first 1000 or Cancel and narrow down your search.'}">
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_notification" />
</tal:block>
<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 tal:define="notification_configuration python: {'class': 'success', 'text': 'Workflow modification in progress.'}">
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_notification" />
</tal:block>
<tr><td>open</td>
<td>${base_url}/Zuite_waitForActivities</td><td></td></tr>
<tr><td>assertTextPresent</td>
<td>Done.</td><td></td></tr>
<tr><td>open</td>
<td>${renderjs_url}/#/foo_module</td><td></td></tr>
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/triggle_filter" />
<tal:block tal:define="filter_section_configuration python: {'index': 0, 'key': 'COLUMN_simulation_state', 'value': 'draft'}">
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/set_filter_section" />
</tal:block>
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/submit_filter" />
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_content_loaded" />
<tal:block tal:define="pagination_configuration python: {'header': '(1 - 3 / 200)', 'footer': 'Records 1 - 3 / 200'}">
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/check_listbox_pagination_text" />
</tal:block>
<!-- clear_query -->
</tbody></table>
</body>
</html>
\ No newline at end of file
......@@ -23,11 +23,11 @@
<td>renderjs_url</td></tr>
<tr><td>open</td>
<td>${base_url}/foo_module/FooModule_createObjects?start:int=10&amp;num:int=5</td><td></td></tr>
<td>${base_url}/foo_module/FooModule_createObjects?start:int=1000&amp;num:int=600</td><td></td></tr>
<tr><td>assertTextPresent</td>
<td>Created Successfully.</td><td></td></tr>
<tr><td>open</td>
<td>${base_url}/foo_module/FooModule_createObjects?start:int=20&amp;num:int=5</td><td></td></tr>
<td>${base_url}/foo_module/FooModule_createObjects?start:int=2000&amp;num:int=600</td><td></td></tr>
<tr><td>assertTextPresent</td>
<td>Created Successfully.</td><td></td></tr>
......@@ -45,7 +45,7 @@
<tr><td>click</td>
<td>//ul[@data-role="listview"]//a[@data-i18n="Empty Mass Action"]</td><td></td></tr>
<tal:block tal:define="pagination_configuration python: {'header': '(1 - 3 / 10)', 'footer': 'Records 1 - 3 / 10'}">
<tal:block tal:define="pagination_configuration python: {'header': '(1 - 3 / 1200)', 'footer': 'Records 1 - 3 / 1200'}">
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/check_listbox_pagination_text" />
</tal:block>
......@@ -55,18 +55,18 @@
<tr><td>click</td>
<td>//div[contains(@data-gadget-url, 'gadget_erp5_field_listbox.html')]//table/thead/tr/th//a[@data-i18n="ID"]</td><td></td></tr>
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_content_loaded" />
<tal:block tal:define="pagination_configuration python: {'header': '(1 - 3 / 10)', 'footer': 'Records 1 - 3 / 10'}">
<tal:block tal:define="pagination_configuration python: {'header': '(1 - 3 / 1200)', 'footer': 'Records 1 - 3 / 1200'}">
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/check_listbox_pagination_text" />
</tal:block>
<tr><td>waitForText</td>
<td>//div[contains(@data-gadget-url, 'gadget_erp5_field_listbox.html')]//table/tbody/tr[1]/td[1]//p</td>
<td>24</td></tr>
<td>2599</td></tr>
<tr><td>waitForText</td>
<td>//div[contains(@data-gadget-url, 'gadget_erp5_field_listbox.html')]//table/tbody/tr[2]/td[1]//p</td>
<td>23</td></tr>
<td>2598</td></tr>
<tr><td>waitForText</td>
<td>//div[contains(@data-gadget-url, 'gadget_erp5_field_listbox.html')]//table/tbody/tr[3]/td[1]//p</td>
<td>22</td></tr>
<td>2597</td></tr>
<tr><td>type</td>
......@@ -78,18 +78,18 @@
<tr><td>click</td>
<td>//div[contains(@data-gadget-url, 'gadget_erp5_field_listbox.html')]//nav/a[@data-i18n="Next"]</td><td></td></tr>
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_content_loaded" />
<tal:block tal:define="pagination_configuration python: {'header': '(4 - 6 / 10)', 'footer': 'Records 4 - 6 / 10'}">
<tal:block tal:define="pagination_configuration python: {'header': '(4 - 6 / 1200)', 'footer': 'Records 4 - 6 / 1200'}">
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/check_listbox_pagination_text" />
</tal:block>
<tr><td>waitForText</td>
<td>//div[contains(@data-gadget-url, 'gadget_erp5_field_listbox.html')]//table/tbody/tr[1]/td[1]//p</td>
<td>21</td></tr>
<td>2596</td></tr>
<tr><td>waitForText</td>
<td>//div[contains(@data-gadget-url, 'gadget_erp5_field_listbox.html')]//table/tbody/tr[2]/td[1]//p</td>
<td>20</td></tr>
<td>2595</td></tr>
<tr><td>waitForText</td>
<td>//div[contains(@data-gadget-url, 'gadget_erp5_field_listbox.html')]//table/tbody/tr[3]/td[1]//p</td>
<td>14</td></tr>
<td>2594</td></tr>
<tr><th rowspan="1" colspan="3">Updating the dialog must not trigger warning about all selected</th></tr>
......@@ -102,7 +102,7 @@
<tr><th rowspan="1" colspan="3">Submitting, however, must warn the user</th></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 tal:define="notification_configuration python: {'class': 'error', 'text': 'All documents are selected! Submit again to proceed or Cancel and narrow down your search.'}">
<tal:block tal:define="notification_configuration python: {'class': 'error', 'text': 'Too many documents selected! Submit again to proceed with the first 1000 or Cancel and narrow down your search.'}">
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_notification" />
</tal:block>
......@@ -152,7 +152,7 @@
<tr><th rowspan="1" colspan="3">Warn the user and compute form_hash in the background</th></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 tal:define="notification_configuration python: {'class': 'error', 'text': 'All documents are selected! Submit again to proceed or Cancel and narrow down your search.'}">
<tal:block tal:define="notification_configuration python: {'class': 'error', 'text': 'Too many documents selected! Submit again to proceed with the first 1000 or Cancel and narrow down your search.'}">
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_notification" />
</tal:block>
......@@ -186,7 +186,7 @@
<tal:block tal:define='search_query string:( title: "Title 1%" )'>
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/search_in_form_list" />
</tal:block>
<tal:block tal:define="pagination_configuration python: {'header': '(1 - 3 / 5)', 'footer': 'Records 1 - 3 / 5'}">
<tal:block tal:define="pagination_configuration python: {'header': '(1 - 3 / 600)', 'footer': 'Records 1 - 3 / 600'}">
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/check_listbox_pagination_text" />
</tal:block>
......@@ -200,7 +200,7 @@
<td>//ul[@data-role="listview"]//a[@data-i18n="Empty Mass Action"]</td><td></td></tr>
<tr><th colspan="3">Make sure that search stays</th></tr>
<tal:block tal:define="pagination_configuration python: {'header': '(1 - 3 / 5)', 'footer': 'Records 1 - 3 / 5'}">
<tal:block tal:define="pagination_configuration python: {'header': '(1 - 3 / 600)', 'footer': 'Records 1 - 3 / 600'}">
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/check_listbox_pagination_text" />
</tal:block>
......@@ -210,7 +210,7 @@
<tr><td>click</td>
<td>//div[contains(@data-gadget-url, 'gadget_erp5_field_listbox.html')]//nav/a[@data-i18n="Next"]</td><td></td></tr>
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_content_loaded" />
<tal:block tal:define="pagination_configuration python: {'header': '(4 - 5 / 5)', 'footer': 'Records 4 - 5 / 5'}">
<tal:block tal:define="pagination_configuration python: {'header': '(4 - 6 / 600)', 'footer': 'Records 4 - 6 / 600'}">
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/check_listbox_pagination_text" />
</tal:block>
......@@ -227,6 +227,36 @@
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_notification" />
</tal:block>
<tr><th colspan="3">Search of too many documents will issue same warnings as no search</th></tr>
<tal:block tal:define='search_query string:( title: "Title 2%" )'>
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/search_in_form_list" />
</tal:block>
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/triggle_filter" />
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/change_filter_to_or" />
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/submit_filter" />
<tal:block tal:define="pagination_configuration python: {'header': '(1 - 3 / 1200)', 'footer': 'Records 1 - 3 / 1200'}">
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/check_listbox_pagination_text" />
</tal:block>
<tr><td>waitForElementPresent</td>
<td>//div[@data-role="header"]//a[@data-i18n="Actions"]</td><td></td></tr>
<tr><td>click</td>
<td>//div[@data-role="header"]//a[@data-i18n="Actions"]</td><td></td></tr>
<tr><td>waitForElementPresent</td>
<td>//ul[@data-role="listview"]//a[@data-i18n="Empty Mass Action"]</td><td></td></tr>
<tr><td>click</td>
<td>//ul[@data-role="listview"]//a[@data-i18n="Empty Mass Action"]</td><td></td></tr>
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_content_loaded" />
<tal:block tal:define="pagination_configuration python: {'header': '(1 - 3 / 1200)', 'footer': 'Records 1 - 3 / 1200'}">
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/check_listbox_pagination_text" />
</tal:block>
<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 tal:define="notification_configuration python: {'class': 'error', 'text': 'Too many documents selected! Submit again to proceed with the first 1000 or Cancel and narrow down your search.'}">
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_notification" />
</tal:block>
</tbody></table>
</body>
</html>
\ No newline at end of file
......@@ -661,6 +661,11 @@
<tr>
<td colspan="3"><b>Change the filter to OR mode</b></td>
</tr>
<tr>
<td>waitForElementPresent</td>
<td>//div[contains(@data-gadget-url, 'gadget_erp5_search_editor.html')]//select[@name='heard_about']</td>
<td></td>
</tr>
<tr>
<td>select</td>
<td>//div[contains(@data-gadget-url, 'gadget_erp5_search_editor.html')]//select[@name='heard_about']</td>
......@@ -950,7 +955,7 @@
<!-- Wait for ckeditor to be loaded :/ How to inspect inside another iframe? -->
<tr>
<td>pause</td>
<td>20000</td>
<td>2000</td>
<td></td>
</tr>
<tr>
......
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