summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorElliot Smith <elliot.smith@intel.com>2016-01-15 13:00:59 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-01-15 16:30:00 +0000
commit112f3746cdaa09c1d7492954e82c2c7158ddae3d (patch)
tree886ce9c4feb8350c8789e89b6dfb272c4f37c50a
parente024aab39cc75d8c0c6068bae07dfb0e758e7157 (diff)
downloadpoky-112f3746cdaa09c1d7492954e82c2c7158ddae3d.tar.gz
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>
-rwxr-xr-xbitbake/lib/toaster/toastergui/views.py3
1 files changed, 3 insertions, 0 deletions
diff --git a/bitbake/lib/toaster/toastergui/views.py b/bitbake/lib/toaster/toastergui/views.py
index fbae36c69c..3e8a66bfb1 100755
--- a/bitbake/lib/toaster/toastergui/views.py
+++ b/bitbake/lib/toaster/toastergui/views.py
@@ -43,6 +43,7 @@ from django.utils.html import escape
43from datetime import timedelta, datetime 43from datetime import timedelta, datetime
44from django.utils import formats 44from django.utils import formats
45from toastergui.templatetags.projecttags import json as jsonfilter 45from toastergui.templatetags.projecttags import json as jsonfilter
46from decimal import Decimal
46import json 47import json
47from os.path import dirname 48from os.path import dirname
48from functools import wraps 49from functools import wraps
@@ -145,6 +146,8 @@ def objtojson(obj):
145 return obj.total_seconds() 146 return obj.total_seconds()
146 elif isinstance(obj, QuerySet) or isinstance(obj, set): 147 elif isinstance(obj, QuerySet) or isinstance(obj, set):
147 return list(obj) 148 return list(obj)
149 elif isinstance(obj, Decimal):
150 return str(obj)
148 elif type(obj).__name__ == "RelatedManager": 151 elif type(obj).__name__ == "RelatedManager":
149 return [x.pk for x in obj.all()] 152 return [x.pk for x in obj.all()]
150 elif hasattr( obj, '__dict__') and isinstance(obj, Model): 153 elif hasattr( obj, '__dict__') and isinstance(obj, Model):