summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bitbake/lib/toaster/toastergui/tables.py75
1 files changed, 73 insertions, 2 deletions
diff --git a/bitbake/lib/toaster/toastergui/tables.py b/bitbake/lib/toaster/toastergui/tables.py
index 43b81a3e79..146a8ddeed 100644
--- a/bitbake/lib/toaster/toastergui/tables.py
+++ b/bitbake/lib/toaster/toastergui/tables.py
@@ -26,6 +26,24 @@ from django.conf.urls import url
26from django.core.urlresolvers import reverse 26from django.core.urlresolvers import reverse
27from django.views.generic import TemplateView 27from django.views.generic import TemplateView
28 28
29
30class ProjectFiltersMixin(object):
31 """Common mixin for recipe, machine in project filters"""
32
33 def filter_in_project(self, count_only=False):
34 query = self.queryset.filter(layer_version__in=self.project_layers)
35 if count_only:
36 return query.count()
37
38 self.queryset = query
39
40 def filter_not_in_project(self, count_only=False):
41 query = self.queryset.exclude(layer_version__in=self.project_layers)
42 if count_only:
43 return query.count()
44
45 self.queryset = query
46
29class LayersTable(ToasterTable): 47class LayersTable(ToasterTable):
30 """Table of layers in Toaster""" 48 """Table of layers in Toaster"""
31 49
@@ -37,12 +55,40 @@ class LayersTable(ToasterTable):
37 context = super(LayersTable, self).get_context_data(**kwargs) 55 context = super(LayersTable, self).get_context_data(**kwargs)
38 56
39 project = Project.objects.get(pk=kwargs['pid']) 57 project = Project.objects.get(pk=kwargs['pid'])
58
40 context['project'] = project 59 context['project'] = project
41 context['projectlayers'] = map(lambda prjlayer: prjlayer.layercommit.id, ProjectLayer.objects.filter(project=project)) 60 context['projectlayers'] = map(lambda prjlayer: prjlayer.layercommit.id, ProjectLayer.objects.filter(project=project))
42 61
43 return context 62 return context
44 63
45 64
65 def setup_filters(self, *args, **kwargs):
66 project = Project.objects.get(pk=kwargs['pid'])
67 self.project_layers = ProjectLayer.objects.filter(project=project)
68
69
70 self.add_filter(title="Filter by project layers",
71 name="in_current_project",
72 filter_actions=[
73 self.make_filter_action("in_project", "Layers added to this project", self.filter_in_project),
74 self.make_filter_action("not_in_project", "Layers not added to this project", self.filter_not_in_project)
75 ])
76
77 def filter_in_project(self, count_only=False):
78 query = self.queryset.filter(projectlayer__in=self.project_layers)
79 if count_only:
80 return query.count()
81
82 self.queryset = query
83
84 def filter_not_in_project(self, count_only=False):
85 query = self.queryset.exclude(projectlayer__in=self.project_layers)
86 if count_only:
87 return query.count()
88
89 self.queryset = query
90
91
46 def setup_queryset(self, *args, **kwargs): 92 def setup_queryset(self, *args, **kwargs):
47 prj = Project.objects.get(pk = kwargs['pid']) 93 prj = Project.objects.get(pk = kwargs['pid'])
48 compatible_layers = prj.compatible_layerversions() 94 compatible_layers = prj.compatible_layerversions()
@@ -140,6 +186,7 @@ class LayersTable(ToasterTable):
140 self.add_column(title="Add | Delete", 186 self.add_column(title="Add | Delete",
141 help_text="Add or delete layers to / from your project", 187 help_text="Add or delete layers to / from your project",
142 hideable=False, 188 hideable=False,
189 filter_name="in_current_project",
143 static_data_name="add-del-layers", 190 static_data_name="add-del-layers",
144 static_data_template='{% include "layer_btn.html" %}') 191 static_data_template='{% include "layer_btn.html" %}')
145 192
@@ -169,7 +216,7 @@ class LayerDetails(ToasterTemplateView):
169 return context 216 return context
170 217
171 218
172class MachinesTable(ToasterTable): 219class MachinesTable(ToasterTable, ProjectFiltersMixin):
173 """Table of Machines in Toaster""" 220 """Table of Machines in Toaster"""
174 221
175 def __init__(self, *args, **kwargs): 222 def __init__(self, *args, **kwargs):
@@ -183,6 +230,16 @@ class MachinesTable(ToasterTable):
183 context['projectlayers'] = map(lambda prjlayer: prjlayer.layercommit.id, ProjectLayer.objects.filter(project=context['project'])) 230 context['projectlayers'] = map(lambda prjlayer: prjlayer.layercommit.id, ProjectLayer.objects.filter(project=context['project']))
184 return context 231 return context
185 232
233 def setup_filters(self, *args, **kwargs):
234 project = Project.objects.get(pk=kwargs['pid'])
235 self.project_layers = project.projectlayer_equivalent_set()
236
237 self.add_filter(title="Filter by project machines",
238 name="in_current_project",
239 filter_actions=[
240 self.make_filter_action("in_project", "Machines provided by layers added to this project", self.filter_in_project),
241 self.make_filter_action("not_in_project", "Machines provided by layers not added to this project", self.filter_not_in_project)
242 ])
186 243
187 def setup_queryset(self, *args, **kwargs): 244 def setup_queryset(self, *args, **kwargs):
188 prj = Project.objects.get(pk = kwargs['pid']) 245 prj = Project.objects.get(pk = kwargs['pid'])
@@ -226,6 +283,7 @@ class MachinesTable(ToasterTable):
226 self.add_column(title="Select", 283 self.add_column(title="Select",
227 help_text="Sets the selected machine as the project machine. You can only have one machine per project", 284 help_text="Sets the selected machine as the project machine. You can only have one machine per project",
228 hideable=False, 285 hideable=False,
286 filter_name="in_current_project",
229 static_data_name="add-del-layers", 287 static_data_name="add-del-layers",
230 static_data_template='{% include "machine_btn.html" %}') 288 static_data_template='{% include "machine_btn.html" %}')
231 289
@@ -264,7 +322,7 @@ class LayerMachinesTable(MachinesTable):
264 static_data_template=select_btn_template) 322 static_data_template=select_btn_template)
265 323
266 324
267class RecipesTable(ToasterTable): 325class RecipesTable(ToasterTable, ProjectFiltersMixin):
268 """Table of Recipes in Toaster""" 326 """Table of Recipes in Toaster"""
269 327
270 def __init__(self, *args, **kwargs): 328 def __init__(self, *args, **kwargs):
@@ -282,6 +340,17 @@ class RecipesTable(ToasterTable):
282 340
283 return context 341 return context
284 342
343 def setup_filters(self, *args, **kwargs):
344 project = Project.objects.get(pk=kwargs['pid'])
345 self.project_layers = project.projectlayer_equivalent_set()
346
347 self.add_filter(title="Filter by project recipes",
348 name="in_current_project",
349 filter_actions=[
350 self.make_filter_action("in_project", "Recipes provided by layers added to this project", self.filter_in_project),
351 self.make_filter_action("not_in_project", "Recipes provided by layers not added to this project", self.filter_not_in_project)
352 ])
353
285 354
286 def setup_queryset(self, *args, **kwargs): 355 def setup_queryset(self, *args, **kwargs):
287 prj = Project.objects.get(pk = kwargs['pid']) 356 prj = Project.objects.get(pk = kwargs['pid'])
@@ -318,6 +387,7 @@ class RecipesTable(ToasterTable):
318 387
319 self.add_column(title="Recipe file", 388 self.add_column(title="Recipe file",
320 help_text="Path to the recipe .bb file", 389 help_text="Path to the recipe .bb file",
390 hidden=True,
321 static_data_name="recipe-file", 391 static_data_name="recipe-file",
322 static_data_template=recipe_file_template) 392 static_data_template=recipe_file_template)
323 393
@@ -348,6 +418,7 @@ class RecipesTable(ToasterTable):
348 self.add_column(title="Build", 418 self.add_column(title="Build",
349 help_text="Add or delete recipes to and from your project", 419 help_text="Add or delete recipes to and from your project",
350 hideable=False, 420 hideable=False,
421 filter_name="in_current_project",
351 static_data_name="add-del-layers", 422 static_data_name="add-del-layers",
352 static_data_template='{% include "recipe_btn.html" %}') 423 static_data_template='{% include "recipe_btn.html" %}')
353 424