Commit 663c6025 authored by Tomáš Peterka's avatar Tomáš Peterka

[erp5_core] Replace `uids` with `query` for mass transition to prevent multiple searches

parent 3a811c0e
......@@ -203,7 +203,7 @@
<tr><td>assertElementPresent</td>
<td>//select[@name="field_workflow_action"]/option[@value="invalidate_action"]</td><td></td></tr>
<tr><th>Check Listbox filtering of documents with available selected action</th><tr>
<tr><th colspan="3">Check Listbox filtering of documents with available selected action</th><tr>
<tr><td>waitForElementPresent</td>
<td>//select[@name="field_workflow_action"]/option[@value="validate_action"]</td><td></td></tr>
<tr><td>select</td>
......@@ -211,7 +211,7 @@
<td>value=validate_action</td></tr>
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/submit_dialog" />
<tal:block tal:define="notification_configuration python: {'class': 'error', 'text': 'Form updated.'}">
<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 metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_notification" />
</tal:block>
......@@ -290,6 +290,52 @@
<tr><td>select</td>
<td>//select[@name="field_workflow_action"]</td>
<td>value=invalidate_action</td></tr>
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/submit_dialog" />
<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 metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_notification" />
</tal:block>
<tr><td>waitForElementPresent</td>
<td>//textarea[@name="field_workflow_dialog_your_comment"]</td><td></td></tr>
<tr><td>type</td>
<td>//textarea[@name="field_workflow_dialog_your_comment"]</td>
<td>Pain perdu</td></tr>
<tr><td>pause</td><td>2000</td><td></td></tr>
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/submit_dialog" />
<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 tal:define="pagination_configuration python: {'header': '(1 - 3 / 6)', 'footer': 'Records 1 - 3 / 6'}">
<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"]//tbody/tr[1]/td[1]//a</td><td></td></tr>
<tr><td>click</td>
<td>//div[@data-gadget-scope="field_listbox"]//tbody/tr[1]/td[1]//a</td><td></td></tr>
<tr><td>waitForElementPresent</td>
<td>//div[@data-role="header"]//a[@data-i18n="Views"]</td><td></td></tr>
<tr><td>click</td>
<td>//div[@data-role="header"]//a[@data-i18n="Views"]</td><td></td></tr>
<tr><td>waitForElementPresent</td>
<td>//div[@role="main"]//ul[@data-role="listview"]//a[@data-i18n="History"]</td><td></td></tr>
<tr><td>click</td>
<td>//div[@role="main"]//ul[@data-role="listview"]//a[@data-i18n="History"]</td><td></td></tr>
<tr><td>waitForTextPresent</td>
<td>Pain perdu</td><td></td></tr>
<tr><td>assertTextPresent</td>
<td>Pain perdu</td><td></td></tr>
</tbody></table>
</body>
</html>
\ No newline at end of file
......@@ -66,7 +66,7 @@
<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 50 or Cancel and narrow down your search.'}">
<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 metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_notification" />
</tal:block>
<tr><td>pause</td>
......
......@@ -21,7 +21,7 @@ request = kwargs.get("REQUEST", None) or context.REQUEST
translate = portal.Base_translateString
# Ensure the selected action is doable on received objects
document_list = [result.getObject() for result in portal.portal_catalog.searchResults(uid=uids)]
document_list = context.Base_searchUsingFormIdAndQuery(form_id, query, limit=50)
workflowable_list = []
if not workflow_action:
......@@ -43,7 +43,7 @@ workflow_dialog = None
if workflow_action_rendered != workflow_action:
# if we get all fields for the workflow form - do not bother user and proceed
try:
workflow_dialog_id = context.Base_getFormIdForWorkflowAction(form_id, '', workflow_action, uids=uids)
workflow_dialog_id = context.Base_getFormIdForWorkflowAction(form_id, query, workflow_action)
workflow_dialog = getattr(context, workflow_dialog_id) # this can throw if form is not defined yet
for group in workflow_dialog.get_groups():
if group.lower() == 'hidden':
......@@ -57,9 +57,10 @@ if workflow_action_rendered != workflow_action:
level="warning",
REQUEST=request)
for document in document_list:
for document in (result.getObject() for result in document_list):
try:
# Kato: Why does it throw an axception instead of just returning False?
# And even more it works only on real objects and not "brains"
portal.portal_workflow.canDoActionFor(document, workflow_action)
except WorkflowException as exception:
pass
......@@ -76,7 +77,7 @@ batch_size = 100
workflow_action_kwargs = {}
if workflow_dialog is None:
workflow_dialog_id = context.Base_getFormIdForWorkflowAction(form_id, '', workflow_action, uids=uids)
workflow_dialog_id = context.Base_getFormIdForWorkflowAction(form_id, query, workflow_action)
workflow_dialog = getattr(context, workflow_dialog_id)
try:
workflow_action_kwargs = workflow_dialog.validate_all(request, key_prefix='field_workflow_dialog')
......
......@@ -50,7 +50,7 @@
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>form_id, dialog_id, uids, workflow_action, workflow_action_rendered, comment=\'\', **kwargs</string> </value>
<value> <string>form_id, dialog_id, query, workflow_action, workflow_action_rendered, comment=\'\', **kwargs</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