summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/toaster/toastergui/widgets.py
diff options
context:
space:
mode:
authorAlexandru DAMIAN <alexandru.damian@intel.com>2015-06-08 11:01:43 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-06-12 00:01:48 +0100
commit58600cf8e76f270969ded6ec63ac0908f39dae09 (patch)
treef87738a1ce5857a576c236f43b85b3ec83089c88 /bitbake/lib/toaster/toastergui/widgets.py
parent4a2a057130e877eae96d726bc86c6b9f48ed1ca3 (diff)
downloadpoky-58600cf8e76f270969ded6ec63ac0908f39dae09.tar.gz
bitbake: toaster: toaster table add raw data
We add in a JSON response both the raw data and the rendered version for display. The rendered fields start with "static:" to mark a different "namespace". The toaster.js is updated to always display the "static:" version of a field, if it exists (and ignore the raw data unless the static rendering is missing). (Bitbake rev: 928ee3fd4b52ea14b7eb704f1f27351362a9d27a) Signed-off-by: Alexandru DAMIAN <alexandru.damian@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/toaster/toastergui/widgets.py')
-rw-r--r--bitbake/lib/toaster/toastergui/widgets.py16
1 files changed, 11 insertions, 5 deletions
diff --git a/bitbake/lib/toaster/toastergui/widgets.py b/bitbake/lib/toaster/toastergui/widgets.py
index 4347a3f081..82b7514bd8 100644
--- a/bitbake/lib/toaster/toastergui/widgets.py
+++ b/bitbake/lib/toaster/toastergui/widgets.py
@@ -37,6 +37,7 @@ import json
37import collections 37import collections
38import operator 38import operator
39 39
40from toastergui.views import objtojson
40 41
41class ToasterTable(TemplateView): 42class ToasterTable(TemplateView):
42 def __init__(self, *args, **kwargs): 43 def __init__(self, *args, **kwargs):
@@ -275,19 +276,25 @@ class ToasterTable(TemplateView):
275 276
276 for col in self.columns: 277 for col in self.columns:
277 field = col['field_name'] 278 field = col['field_name']
279 if not field:
280 field = col['static_data_name']
281 if not field:
282 raise Exception("Must supply a field_name or static_data_name for column %s.%s" % (self.__class__.__name__,col))
278 # Check if we need to process some static data 283 # Check if we need to process some static data
279 if "static_data_name" in col and col['static_data_name']: 284 if "static_data_name" in col and col['static_data_name']:
280 required_data[col['static_data_name']] = self.render_static_data(col['static_data_template'], row) 285 required_data["static:%s" % col['static_data_name']] = self.render_static_data(col['static_data_template'], row)
281 286
282 # Overwrite the field_name with static_data_name 287 # Overwrite the field_name with static_data_name
283 # so that this can be used as the html class name 288 # so that this can be used as the html class name
284 289
285 col['field_name'] = col['static_data_name'] 290 col['field_name'] = col['static_data_name']
286 else: 291
292 if True: # we add the raw model data at all times
287 model_data = row 293 model_data = row
288 # Traverse to any foriegn key in the object hierachy 294 # Traverse to any foriegn key in the object hierachy
289 for subfield in field.split("__"): 295 for subfield in field.split("__"):
290 model_data = getattr(model_data, subfield) 296 if hasattr(model_data, subfield):
297 model_data = getattr(model_data, subfield)
291 # The field could be a function on the model so check 298 # The field could be a function on the model so check
292 # If it is then call it 299 # If it is then call it
293 if isinstance(model_data, types.MethodType): 300 if isinstance(model_data, types.MethodType):
@@ -299,8 +306,7 @@ class ToasterTable(TemplateView):
299 306
300 except FieldError: 307 except FieldError:
301 print "Error: Requested field does not exist" 308 print "Error: Requested field does not exist"
302 309 data = json.dumps(data, indent=2, default=objtojson)
303 data = json.dumps(data, indent=2, cls=DjangoJSONEncoder)
304 cache.set(cache_name, data, 60*30) 310 cache.set(cache_name, data, 60*30)
305 311
306 return data 312 return data