aboutsummaryrefslogtreecommitdiffstats
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)
downloadopenembedded-core-contrib-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):
cache.set(cache_name, data, 60*30)
return data
+
+
+class ToasterTemplateView(TemplateView):
+ # renders a instance in a template, or returns the context as json
+ # the class-equivalent of the _template_renderer decorator for views
+
+
+ def get(self, *args, **kwargs):
+ if self.request.GET.get('format', None) == 'json':
+ from django.core.urlresolvers import reverse
+ from django.shortcuts import HttpResponse
+ from views import objtojson
+ from toastergui.templatetags.projecttags import json as jsonfilter
+
+ context = self.get_context_data(**kwargs)
+
+ for x in context.keys():
+ if x not in self.context_entries:
+ del context[x]
+
+ context["error"] = "ok"
+
+ return HttpResponse(jsonfilter(context, default=objtojson ),
+ content_type = "application/json; charset=utf-8")
+
+ return super(ToasterTemplateView, self).get(*args, **kwargs)