summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/toaster/toastergui/widgets.py
diff options
context:
space:
mode:
authorAlexandru DAMIAN <alexandru.damian@intel.com>2015-06-08 11:12:47 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-06-12 00:01:48 +0100
commit7c2b86625b75f0c3c5447d240175558be1e37919 (patch)
tree103e2efd1fdb6de3c198ff475fe9380302e2d6eb /bitbake/lib/toaster/toastergui/widgets.py
parent51ae1de5b75b6f831b46433b2e36c6112d1a0c59 (diff)
downloadpoky-7c2b86625b75f0c3c5447d240175558be1e37919.tar.gz
bitbake: toaster: add class template view for single-object pages
Adding ToasterTemplateView as prototype for all class-based views that display single objects; equivalent to ToasterTable for object lists. (Bitbake rev: d3edea773000a663f5883e04f477d853bff64cf6) 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.py26
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
330class 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)