mirror of
https://git.yoctoproject.org/poky
synced 2026-09-14 03:49:32 +02:00
bitbake: toastergui: serialise decimals correctly
The conversion of some ToasterTable Build object querysets to JSON caused a serialisation error. This is because one of the fields in the queryset was of type decimal.Decimal, and our serialiser didn't know what to do with it. Add a clause to check for decimal fields and serialise them so that correct JSON can be generated. (Bitbake rev: fa6229d4edf5904ccaa9dc323d0ab2318d1ef314) Signed-off-by: Elliot Smith <elliot.smith@intel.com> Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
committed by
Richard Purdie
parent
e024aab39c
commit
112f3746cd
@@ -43,6 +43,7 @@ from django.utils.html import escape
|
|||||||
from datetime import timedelta, datetime
|
from datetime import timedelta, datetime
|
||||||
from django.utils import formats
|
from django.utils import formats
|
||||||
from toastergui.templatetags.projecttags import json as jsonfilter
|
from toastergui.templatetags.projecttags import json as jsonfilter
|
||||||
|
from decimal import Decimal
|
||||||
import json
|
import json
|
||||||
from os.path import dirname
|
from os.path import dirname
|
||||||
from functools import wraps
|
from functools import wraps
|
||||||
@@ -145,6 +146,8 @@ def objtojson(obj):
|
|||||||
return obj.total_seconds()
|
return obj.total_seconds()
|
||||||
elif isinstance(obj, QuerySet) or isinstance(obj, set):
|
elif isinstance(obj, QuerySet) or isinstance(obj, set):
|
||||||
return list(obj)
|
return list(obj)
|
||||||
|
elif isinstance(obj, Decimal):
|
||||||
|
return str(obj)
|
||||||
elif type(obj).__name__ == "RelatedManager":
|
elif type(obj).__name__ == "RelatedManager":
|
||||||
return [x.pk for x in obj.all()]
|
return [x.pk for x in obj.all()]
|
||||||
elif hasattr( obj, '__dict__') and isinstance(obj, Model):
|
elif hasattr( obj, '__dict__') and isinstance(obj, Model):
|
||||||
|
|||||||
Reference in New Issue
Block a user