Commit 34cc3871 authored by Tomáš Peterka's avatar Tomáš Peterka

[renderjs_ui + json_style] Deletion of an object returns meaningful response

parent 3bc2302e
from ZODB.POSException import ConflictError """Delete object - this script is called as the last frontier thus its result
gets printed into response body.
""" The code is a modified version of Folder_delete. We split into two files not to
some duplicated code with Folder_delete instead of modify Folder_delete further complicate the mentioned script.
intended to make code easy understanding
""" """
portal = context.getPortalObject() from ZODB.POSException import ConflictError
portal = context.getPortalObject()
translate = portal.Base_translateString
if context.isDeletable(check_relation=True): if context.isDeletable(check_relation=True):
parent = context.getParentValue() parent = context.getParentValue()
...@@ -16,10 +18,16 @@ if context.isDeletable(check_relation=True): ...@@ -16,10 +18,16 @@ if context.isDeletable(check_relation=True):
portal.portal_workflow.doActionFor(context, 'delete_action') portal.portal_workflow.doActionFor(context, 'delete_action')
else: else:
parent.manage_delObjects(ids= [context.getId()]) parent.manage_delObjects(ids= [context.getId()])
return # redirect back to the container since the context was deleted
return container.Base_redirect(
keep_items={
"portal_status_message": translate("Document deleted")
})
except ConflictError: except ConflictError:
raise raise
except Exception: except Exception:
# XXX Catch-them-all expression is never a good idea
pass pass
request = portal.REQUEST request = portal.REQUEST
......
...@@ -176,21 +176,20 @@ ...@@ -176,21 +176,20 @@
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/submit_dialog" /> <tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/submit_dialog" />
<tr> <!-- Deletion of a Foo Document will still show it in Module View but with "deleted" state -->
<td>waitForTextPresent</td> <tr><td>waitForElementPresent</td>
<td>deleted</td> <td>//div[contains(@data-gadget-url, 'gadget_erp5_pt_form_list.html')]//div[@data-gadget-scope="field_listbox"]//a[text()="deleted"]</td><td></td></tr>
<td></td>
</tr> <tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/toggle_editable_mode" />
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_content_loaded" />
<!-- We should see only one Foo Document -->
<tr> <tr>
<td>verifyTextPresent</td> <td>waitForElementPresent</td>
<td>deleted</td> <td>//div[contains(@data-gadget-url, 'gadget_erp5_pt_form_list.html')]//div[@data-gadget-scope="field_listbox"]//a[@class="ui-link"]</td>
<td></td> <td></td>
</tr> </tr>
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/toggle_editable_mode" />
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_content_loaded" />
<tr> <tr>
<td>click</td> <td>click</td>
<td>//div[contains(@data-gadget-url, 'gadget_erp5_pt_form_list.html')]//div[@data-gadget-scope="field_listbox"]//a[@class="ui-link"]</td> <td>//div[contains(@data-gadget-url, 'gadget_erp5_pt_form_list.html')]//div[@data-gadget-scope="field_listbox"]//a[@class="ui-link"]</td>
......
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_content_loaded" /> <tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_content_loaded" />
<tr> <tr>
<td>verifyElementPresent</td> <td>waitForElementPresent</td>
<td>//div[@data-gadget-scope='field_my_title']//input</td> <td>//div[@data-gadget-scope='field_my_title']//input</td>
<td></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