Commit 08b36214 authored by Romain Courteaud's avatar Romain Courteaud

erp5_hal_json_style: support DateTime in GadgetField parameters

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