Commit bf0156f7 authored by Romain Courteaud's avatar Romain Courteaud

erp5_hal_json_style: support DateTime in GadgetField parameters

parent 8c33124e
......@@ -93,6 +93,8 @@ def toBasicTypes(obj):
return tuple(toBasicTypes(x) for x in obj)
if isinstance(obj, Message):
return obj.translate()
if isinstance(obj, DateTime):
return obj.rfc822()
try:
return {toBasicTypes(key): toBasicTypes(obj[key]) for key in obj}
except Exception:
......@@ -700,7 +702,7 @@ def renderField(traversed_document, field, form, value=MARKER, meta_type=None,
"sandbox": field.get_value("js_sandbox")
})
try:
result["renderjs_extra"] = json.dumps(dict(field.get_value("renderjs_extra")))
result["renderjs_extra"] = json.dumps(toBasicTypes(dict(field.get_value("renderjs_extra"))))
except KeyError:
# Ensure compatibility if the products are not yet up to date
result["renderjs_extra"] = json.dumps({})
......
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