Commit f379099c authored by Romain Courteaud's avatar Romain Courteaud

erp5_hal_json_style: set extra_param_json in request when rendering a form

parent b1dfe137
......@@ -1367,6 +1367,20 @@ def calculateHateoas(is_portal=None, is_site_root=None, traversed_document=None,
'status': statusLevelToString(portal_status_level)
}
if (mode == 'form') or (mode == 'traverse'):
# extra_param_json should be base64 encoded JSON at this point
# only for mode == 'form' it is already a dictionary
if not extra_param_json:
extra_param_json = {}
if isinstance(extra_param_json, str):
extra_param_json = ensureDeserialized(byteify(json.loads(urlsafe_b64decode(extra_param_json))))
# Use extra param as request param
for k, v in byteify(extra_param_json.items()):
REQUEST.set(k, v)
REQUEST.form[k] = v
if (mode == 'root') or (mode == 'traverse'):
##
# Render ERP Document with a `view` specified
......@@ -1391,19 +1405,6 @@ def calculateHateoas(is_portal=None, is_site_root=None, traversed_document=None,
"title": result_dict['title']
}
# extra_param_json should be base64 encoded JSON at this point
# only for mode == 'form' it is already a dictionary
if not extra_param_json:
extra_param_json = {}
if isinstance(extra_param_json, str):
extra_param_json = ensureDeserialized(byteify(json.loads(urlsafe_b64decode(extra_param_json))))
# Use extra param as request param
for k, v in byteify(extra_param_json.items()):
REQUEST.set(k, v)
REQUEST.form[k] = v
# Add a link to the portal type if possible
if not is_portal:
# traversed_document should always have its Portal Type in ERP5 Portal Types
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ActionInformation" module="Products.CMFCore.ActionInformation"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>action</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>action_type/object_jio_action</string>
</tuple>
</value>
</item>
<item>
<key> <string>category</string> </key>
<value> <string>object_jio_action</string> </value>
</item>
<item>
<key> <string>condition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>icon</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>update_request_content</string> </value>
</item>
<item>
<key> <string>language</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>permissions</string> </key>
<value>
<tuple>
<string>View</string>
</tuple>
</value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Action Information</string> </value>
</item>
<item>
<key> <string>priority</string> </key>
<value> <float>2.0</float> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Update Request Content</string> </value>
</item>
<item>
<key> <string>visible</string> </key>
<value> <int>1</int> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="Expression" module="Products.CMFCore.Expression"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>text</string> </key>
<value> <string>string:${object_url}/Foo_viewManuallyUpdatedRequestDialog</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?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>testDialogManuallyUpdateRequest</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 Dialog Manually Update Request</title>
</head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<thead>
<tr><td rowspan="1" colspan="3">Test updating some request variables</td></tr>
</thead><tbody>
<tal:block metal:use-macro="here/PTZuite_CommonTemplate/macros/init" />
<tr>
<td>open</td>
<td tal:content="string: ${here/portal_url}/foo_module/1/Foo_viewManuallyUpdatedRequestDialog">/erp5/foo_module/1/Foo_viewManuallyUpdatedRequestDialog</td>
<td></td>
</tr>
<tr>
<td>assertValue</td>
<td>field_your_custom_string</td>
<td>Default string from TALES</td>
</tr>
<tr>
<td>assertValue</td>
<td>field_your_custom_integer</td>
<td>-999</td>
</tr>
<tr>
<td>assertValue</td>
<td>field_your_custom_textarea</td>
<td>Default text from TALES</td>
</tr>
<tr>
<td>assertValue</td>
<td>field_your_custom_listfield</td>
<td>Default list from TALES</td>
</tr>
<tr>
<td>clickAndWait</td>
<td>dialog_submit_button</td>
<td></td>
</tr>
<tr>
<td>assertValue</td>
<td>field_your_custom_string</td>
<td>Default string from TALES+</td>
</tr>
<tr>
<td>assertValue</td>
<td>field_your_custom_integer</td>
<td>-998</td>
</tr>
<tr>
<td>assertValue</td>
<td>field_your_custom_textarea</td>
<td>Default text from TALES!</td>
</tr>
<tr>
<td>assertValue</td>
<td>field_your_custom_listfield</td>
<td>Default list from TALES$</td>
</tr>
<tr>
<td>clickAndWait</td>
<td>dialog_submit_button</td>
<td></td>
</tr>
<tr>
<td>assertValue</td>
<td>field_your_custom_string</td>
<td>Default string from TALES++</td>
</tr>
<tr>
<td>assertValue</td>
<td>field_your_custom_integer</td>
<td>-997</td>
</tr>
<tr>
<td>assertValue</td>
<td>field_your_custom_textarea</td>
<td>Default text from TALES!!</td>
</tr>
<tr>
<td>assertValue</td>
<td>field_your_custom_listfield</td>
<td>Default list from TALES$$</td>
</tr>
</body>
</html>
\ No newline at end of file
custom_string += '+'
custom_textarea += '!'
custom_integer += 1
custom_listfield += '$'
custom_radio += '@'
return context.Base_renderForm("Foo_viewManuallyUpdatedRequestDialog", keep_items={
'your_custom_string': custom_string,
'your_custom_textarea': custom_textarea,
'your_custom_integer': custom_integer,
'your_custom_listfield': custom_listfield,
'your_custom_radio': custom_radio
})
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<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_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<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>_params</string> </key>
<value> <string>custom_radio=\'\', custom_string=\'\', custom_integer=0, custom_textarea=\'\', custom_listfield=\'\', **kw</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Foo_updateManuallyRequest</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ERP5 Form" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_objects</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>action</string> </key>
<value> <string>Foo_updateManuallyRequest</string> </value>
</item>
<item>
<key> <string>action_title</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>edit_order</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>encoding</string> </key>
<value> <string>UTF-8</string> </value>
</item>
<item>
<key> <string>enctype</string> </key>
<value> <string>application/x-www-form-urlencoded</string> </value>
</item>
<item>
<key> <string>group_list</string> </key>
<value>
<list>
<string>left</string>
<string>right</string>
<string>center</string>
<string>bottom</string>
<string>hidden</string>
</list>
</value>
</item>
<item>
<key> <string>groups</string> </key>
<value>
<dictionary>
<item>
<key> <string>bottom</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>center</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>hidden</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>left</string> </key>
<value>
<list>
<string>your_custom_string</string>
<string>your_custom_integer</string>
<string>your_custom_textarea</string>
<string>your_custom_listfield</string>
<string>your_custom_radio</string>
</list>
</value>
</item>
<item>
<key> <string>right</string> </key>
<value>
<list/>
</value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Foo_viewManuallyUpdatedRequestDialog</string> </value>
</item>
<item>
<key> <string>method</string> </key>
<value> <string>POST</string> </value>
</item>
<item>
<key> <string>name</string> </key>
<value> <string>Foo_viewManuallyUpdatedRequestDialog</string> </value>
</item>
<item>
<key> <string>pt</string> </key>
<value> <string>form_dialog</string> </value>
</item>
<item>
<key> <string>row_length</string> </key>
<value> <int>4</int> </value>
</item>
<item>
<key> <string>stored_encoding</string> </key>
<value> <string>UTF-8</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Manually Update the Request</string> </value>
</item>
<item>
<key> <string>unicode_mode</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>update_action</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>update_action_title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -35,6 +35,7 @@ Foo | python_action_jio
Foo | python_error_action_jio
Foo | python_failing_action_jio
Foo | select_bar
Foo | update_request_content
Foo | view
Foo | view_action_title
Foo | view_crash_on_save
......
<?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>testFormDialogManuallyUpdateRequest</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 Form View Editable Save Action</title>
</head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<thead>
<tr><td rowspan="1" colspan="3">Test Dialog Without Action</td></tr>
</thead><tbody>
<tal:block metal:use-macro="here/PTZuite_CommonTemplate/macros/init" />
<tr>
<td>open</td>
<td>${base_url}/web_site_module/renderjs_runner/#/foo_module/1?editable=1</td>
<td></td>
</tr>
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_app_loaded" />
<tal:block tal:define="click_configuration python: {'text': 'Actions'}">
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/click_on_header_link" />
</tal:block>
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_content_loaded" />
<tal:block tal:define="click_configuration python: {'text': 'Update Request Content'}">
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/click_on_page_link" />
</tal:block>
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_content_loaded" />
<tr>
<td>assertValue</td>
<td>field_your_custom_string</td>
<td>Default string from TALES</td>
</tr>
<tr>
<td>assertValue</td>
<td>field_your_custom_integer</td>
<td>-999</td>
</tr>
<tr>
<td>assertValue</td>
<td>field_your_custom_textarea</td>
<td>Default text from TALES</td>
</tr>
<tr>
<td>assertValue</td>
<td>field_your_custom_listfield</td>
<td>Default list from TALES</td>
</tr>
<!--tr>
<td>assertValue</td>
<td>field_your_custom_radio</td>
<td>Default radio from TALES</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': 'success', 'text': 'Data received.'}">
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_notification" />
</tal:block>
<tr>
<td>assertValue</td>
<td>field_your_custom_string</td>
<td>Default string from TALES+</td>
</tr>
<tr>
<td>assertValue</td>
<td>field_your_custom_integer</td>
<td>-998</td>
</tr>
<tr>
<td>assertValue</td>
<td>field_your_custom_textarea</td>
<td>Default text from TALES!</td>
</tr>
<tr>
<td>assertValue</td>
<td>field_your_custom_listfield</td>
<td>Default list from TALES$</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': 'success', 'text': 'Data received.'}">
<tal:block metal:use-macro="here/Zuite_CommonTemplateForRenderjsUi/macros/wait_for_notification" />
</tal:block>
<tr>
<td>assertValue</td>
<td>field_your_custom_string</td>
<td>Default string from TALES++</td>
</tr>
<tr>
<td>assertValue</td>
<td>field_your_custom_integer</td>
<td>-997</td>
</tr>
<tr>
<td>assertValue</td>
<td>field_your_custom_textarea</td>
<td>Default text from TALES!!</td>
</tr>
<tr>
<td>assertValue</td>
<td>field_your_custom_listfield</td>
<td>Default list from TALES$$</td>
</tr>
</tbody></table>
</body>
</html>
\ No newline at end of file
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