From 8b0f034213847d9a88b7ccae2efac82d4338461f Mon Sep 17 00:00:00 2001 From: Romain Courteaud <romain@nexedi.com> Date: Wed, 8 Dec 2021 17:23:05 +0000 Subject: [PATCH] erp5_web_renderjs_ui: XXX do not crash if a document can not be accessed --- .../rjs_gadget_erp5_page_form_js.js | 17 +++++++++++++++++ .../rjs_gadget_erp5_page_form_js.xml | 4 ++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_page_form_js.js b/bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_page_form_js.js index d063da7e66..ddd6e1c7bb 100644 --- a/bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_page_form_js.js +++ b/bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_page_form_js.js @@ -274,6 +274,23 @@ and handling data send&receive. new_state.erp5_document = JSON.stringify(new_state.erp5_document); return gadget.changeState(new_state); + }) + .push(undefined, function (error) { + if ((error instanceof jIO.util.jIOError) && + (error.status_code === 404)) { + // If user is authenticated, hal style return 404 in case of unauthorized + // XXX use 403 instead? + // redirect user to the parent page with a message? + // XXX couscous + return gadget.notifySubmitted({ + 'message': error.message, + 'status': 'error' + }) + .push(function () { + return gadget.redirect({command: 'history_previous'}); + }); + } + throw error; }); }) diff --git a/bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_page_form_js.xml b/bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_page_form_js.xml index b818e102be..5213dcd194 100644 --- a/bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_page_form_js.xml +++ b/bt5/erp5_web_renderjs_ui/PathTemplateItem/web_page_module/rjs_gadget_erp5_page_form_js.xml @@ -234,7 +234,7 @@ </item> <item> <key> <string>serial</string> </key> - <value> <string>999.25844.45625.48025</string> </value> + <value> <string>996.45584.23925.17988</string> </value> </item> <item> <key> <string>state</string> </key> @@ -252,7 +252,7 @@ </tuple> <state> <tuple> - <float>1649336938.64</float> + <float>1638984141.13</float> <string>UTC</string> </tuple> </state> -- 2.30.9