diff options
Diffstat (limited to 'bitbake/lib/toaster/toastergui/widgets.py')
-rw-r--r-- | bitbake/lib/toaster/toastergui/widgets.py | 47 |
1 files changed, 19 insertions, 28 deletions
diff --git a/bitbake/lib/toaster/toastergui/widgets.py b/bitbake/lib/toaster/toastergui/widgets.py index 8cf6e1bc2d..4347a3f081 100644 --- a/bitbake/lib/toaster/toastergui/widgets.py +++ b/bitbake/lib/toaster/toastergui/widgets.py | |||
@@ -32,29 +32,17 @@ from django.core.serializers.json import DjangoJSONEncoder | |||
32 | from django.core.exceptions import FieldError | 32 | from django.core.exceptions import FieldError |
33 | from django.conf.urls import url, patterns | 33 | from django.conf.urls import url, patterns |
34 | 34 | ||
35 | import urls | ||
36 | import types | 35 | import types |
37 | import json | 36 | import json |
38 | import collections | 37 | import collections |
39 | import operator | 38 | import operator |
40 | 39 | ||
41 | 40 | ||
42 | class ToasterTemplateView(TemplateView): | 41 | class ToasterTable(TemplateView): |
43 | def get_context_data(self, **kwargs): | 42 | def __init__(self, *args, **kwargs): |
44 | context = super(ToasterTemplateView, self).get_context_data(**kwargs) | 43 | super(ToasterTable, self).__init__() |
45 | if 'pid' in kwargs: | 44 | if 'template_name' in kwargs: |
46 | context['project'] = Project.objects.get(pk=kwargs['pid']) | 45 | self.template_name = kwargs['template_name'] |
47 | |||
48 | context['projectlayers'] = map(lambda prjlayer: prjlayer.layercommit.id, ProjectLayer.objects.filter(project=context['project'])) | ||
49 | |||
50 | if 'layerid' in kwargs: | ||
51 | context['layerversion'] = Layer_Version.objects.get(pk=kwargs['layerid']) | ||
52 | |||
53 | return context | ||
54 | |||
55 | |||
56 | class ToasterTable(View): | ||
57 | def __init__(self): | ||
58 | self.title = None | 46 | self.title = None |
59 | self.queryset = None | 47 | self.queryset = None |
60 | self.columns = [] | 48 | self.columns = [] |
@@ -66,20 +54,23 @@ class ToasterTable(View): | |||
66 | self.default_orderby = "" | 54 | self.default_orderby = "" |
67 | 55 | ||
68 | def get(self, request, *args, **kwargs): | 56 | def get(self, request, *args, **kwargs): |
69 | self.setup_queryset(*args, **kwargs) | 57 | if request.GET.get('format', None) == 'json': |
70 | 58 | ||
71 | # Put the project id into the context for the static_data_template | 59 | self.setup_queryset(*args, **kwargs) |
72 | if 'pid' in kwargs: | 60 | # Put the project id into the context for the static_data_template |
73 | self.static_context_extra['pid'] = kwargs['pid'] | 61 | if 'pid' in kwargs: |
62 | self.static_context_extra['pid'] = kwargs['pid'] | ||
74 | 63 | ||
75 | cmd = kwargs['cmd'] | 64 | cmd = request.GET.get('cmd', None) |
76 | if cmd and 'filterinfo' in cmd: | 65 | if cmd and 'filterinfo' in cmd: |
77 | data = self.get_filter_info(request) | 66 | data = self.get_filter_info(request) |
78 | else: | 67 | else: |
79 | # If no cmd is specified we give you the table data | 68 | # If no cmd is specified we give you the table data |
80 | data = self.get_data(request, **kwargs) | 69 | data = self.get_data(request, **kwargs) |
70 | |||
71 | return HttpResponse(data, content_type="application/json") | ||
81 | 72 | ||
82 | return HttpResponse(data, content_type="application/json") | 73 | return super(ToasterTable, self).get(request, *args, **kwargs) |
83 | 74 | ||
84 | def get_filter_info(self, request): | 75 | def get_filter_info(self, request): |
85 | data = None | 76 | data = None |