From d6d3df6d5b8b661a69b213dcebf497de6ba45999 Mon Sep 17 00:00:00 2001
From: Romain Courteaud <romain@nexedi.com>
Date: Mon, 4 Aug 2014 13:34:36 +0000
Subject: [PATCH] Put all expected query parameters in the REQUEST

---
 .../erp5_hal_json_style/ERP5Document_getHateoas.xml       | 8 +++++++-
 bt5/erp5_hal_json_style/bt/revision                       | 2 +-
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/bt5/erp5_hal_json_style/SkinTemplateItem/portal_skins/erp5_hal_json_style/ERP5Document_getHateoas.xml b/bt5/erp5_hal_json_style/SkinTemplateItem/portal_skins/erp5_hal_json_style/ERP5Document_getHateoas.xml
index 3540412168..d0765ffd77 100644
--- a/bt5/erp5_hal_json_style/SkinTemplateItem/portal_skins/erp5_hal_json_style/ERP5Document_getHateoas.xml
+++ b/bt5/erp5_hal_json_style/SkinTemplateItem/portal_skins/erp5_hal_json_style/ERP5Document_getHateoas.xml
@@ -477,7 +477,6 @@ elif (mode == \'root\') or (mode == \'traverse\'):\n
     # instead of form, unexpected action TALES expression). Happy debugging.\n
     # renderer_form_relative_url = view_action[\'url\'][len(portal.absolute_url()):]\n
     form_id = embedded_url.split(\'?\', 1)[0].split("/")[-1]\n
-    # XXX Drop (or do something else...) all query parameters (?reset:int=1)\n
     # renderer_form = traversed_document.restrictedTraverse(form_id, None)\n
     # XXX Proxy field are not correctly handled in traversed_document of web site\n
     renderer_form = getattr(traversed_document, form_id)\n
@@ -490,6 +489,13 @@ elif (mode == \'root\') or (mode == \'traverse\'):\n
           }\n
         }\n
       }\n
+      # Put all query parameters (?reset:int=1&workflow_action=start_action) in request to mimic usual form display\n
+      query_split = embedded_url.split(\'?\', 1)\n
+      if len(query_split) == 2:\n
+        for query_parameter in query_split[1].split("&"):\n
+          query_key, query_value = query_parameter.split("=")\n
+          REQUEST.set(query_key, query_value)\n
+\n
       renderForm(renderer_form, embedded_dict)\n
       result_dict[\'_embedded\'] = {\n
         \'_view\': embedded_dict\n
diff --git a/bt5/erp5_hal_json_style/bt/revision b/bt5/erp5_hal_json_style/bt/revision
index 8fdd954df9..b393560759 100644
--- a/bt5/erp5_hal_json_style/bt/revision
+++ b/bt5/erp5_hal_json_style/bt/revision
@@ -1 +1 @@
-22
\ No newline at end of file
+23
\ No newline at end of file
-- 
2.30.9