diff options
Diffstat (limited to 'bitbake/lib/toaster/toastergui/widgets.py')
| -rw-r--r-- | bitbake/lib/toaster/toastergui/widgets.py | 16 |
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 | |||
| 37 | import collections | 37 | import collections |
| 38 | import operator | 38 | import operator |
| 39 | 39 | ||
| 40 | from toastergui.views import objtojson | ||
| 40 | 41 | ||
| 41 | class ToasterTable(TemplateView): | 42 | class 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 |
