Commit 5d240501 authored by Titouan Soulard's avatar Titouan Soulard

erp5_xhtml_style: report error messages on clone as errors

The script `Base_createCloneDocument` was made to be user-friendly, reporting
nice errors instead of throwing when a problems is detected. These errors are
displayed using the `portal_status_message` parameter of `Base_redirect`, which
looks like a warning on XHTML-style, but appears green with RenderJS.

This commit adds an optional parameter `portal_status_level` to all calls to
`Base_redirect` which are actually errors, so that they also look like a
warning or error (orange background) on RenderJS. The behaviour in XHTML-style
says identical.

/cc @romain @vpelletier
parent b2e93a3f
......@@ -25,8 +25,10 @@ if not (portal_type in destination.getVisibleAllowedContentTypeList() and
if batch_mode:
return None
else:
return context.Base_redirect(keep_items={'portal_status_message':
translateString("You are not allowed to clone this object.")})
return context.Base_redirect(keep_items={
'portal_status_message': translateString("You are not allowed to clone this object."),
'portal_status_level': 'error',
})
# prepare query params
kw = {'portal_type' : translateString(portal_type)}
......@@ -36,9 +38,14 @@ if web_mode:
if script is not None:
msg = script(**form_data)
if msg is not None:
return context.Base_redirect(form_id,
editable_mode=editable_mode,
keep_items={'portal_status_message': msg})
return context.Base_redirect(
form_id,
editable_mode=editable_mode,
keep_items={
'portal_status_message': msg,
'portal_status_level': 'error',
}
)
# Standard cloning method
if clone:
......
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