diff options
Diffstat (limited to 'bitbake/lib/toaster/toastergui/widgets.py')
-rw-r--r-- | bitbake/lib/toaster/toastergui/widgets.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/bitbake/lib/toaster/toastergui/widgets.py b/bitbake/lib/toaster/toastergui/widgets.py index 3d3c1d10df..8bc3d7f160 100644 --- a/bitbake/lib/toaster/toastergui/widgets.py +++ b/bitbake/lib/toaster/toastergui/widgets.py | |||
@@ -325,3 +325,29 @@ class ToasterTable(TemplateView): | |||
325 | cache.set(cache_name, data, 60*30) | 325 | cache.set(cache_name, data, 60*30) |
326 | 326 | ||
327 | return data | 327 | return data |
328 | |||
329 | |||
330 | class ToasterTemplateView(TemplateView): | ||
331 | # renders a instance in a template, or returns the context as json | ||
332 | # the class-equivalent of the _template_renderer decorator for views | ||
333 | |||
334 | |||
335 | def get(self, *args, **kwargs): | ||
336 | if self.request.GET.get('format', None) == 'json': | ||
337 | from django.core.urlresolvers import reverse | ||
338 | from django.shortcuts import HttpResponse | ||
339 | from views import objtojson | ||
340 | from toastergui.templatetags.projecttags import json as jsonfilter | ||
341 | |||
342 | context = self.get_context_data(**kwargs) | ||
343 | |||
344 | for x in context.keys(): | ||
345 | if x not in self.context_entries: | ||
346 | del context[x] | ||
347 | |||
348 | context["error"] = "ok" | ||
349 | |||
350 | return HttpResponse(jsonfilter(context, default=objtojson ), | ||
351 | content_type = "application/json; charset=utf-8") | ||
352 | |||
353 | return super(ToasterTemplateView, self).get(*args, **kwargs) | ||