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

[hal_json_style] Set correct HTTP STATUS for invalid form while rendering

/reviewed-on !593
parent 8f9f6ade
# request.RESPONSE.setStatus(200)
form = getattr(context, form_id) form = getattr(context, form_id)
request = REQUEST or context.REQUEST
# HAL JSON uses HTTP codes to communicate what the payload represents
if request.get('field_errors', None):
# HTTP400 means invalid form
request.RESPONSE.setStatus(400)
return context.ERP5Document_getHateoas(form=form, mode='form') return context.ERP5Document_getHateoas(form=form, mode='form')
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string>form_id</string> </value> <value> <string>form_id, REQUEST=None</string> </value>
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
......
...@@ -43,6 +43,9 @@ ...@@ -43,6 +43,9 @@
</tr> </tr>
<!-- Do not fill anything to provoke form validation failure --> <!-- Do not fill anything to provoke form validation failure -->
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/submit_dialog" /> <tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/submit_dialog" />
<tal:block tal:define="notification_configuration python: {'class': 'error', 'text': 'Input data has errors.'}">
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_notification" />
</tal:block>
<tr><td>waitForElementPresent</td> <tr><td>waitForElementPresent</td>
<td>//div[@data-gadget-scope="field_your_custom_workflow_variable"]/div/span</td><td></td></tr> <td>//div[@data-gadget-scope="field_your_custom_workflow_variable"]/div/span</td><td></td></tr>
<tr><td>assertText</td> <tr><td>assertText</td>
...@@ -60,8 +63,7 @@ ...@@ -60,8 +63,7 @@
<!-- Wait for the notification to appear. We cannot use verifyText because the button <!-- Wait for the notification to appear. We cannot use verifyText because the button
is there all the time. It gets text assigned and is shown asynchronously later. --> is there all the time. It gets text assigned and is shown asynchronously later. -->
<tal:block tal:define="notification_configuration python: {'class': 'success', <tal:block tal:define="notification_configuration python: {'class': 'success', 'text': 'Status changed.'}">
'text': 'Status changed.'}">
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_notification" /> <tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_notification" />
</tal:block> </tal:block>
</tbody></table> </tbody></table>
......
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