summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/toaster/toastergui/tables.py
diff options
context:
space:
mode:
authorElliot Smith <elliot.smith@intel.com>2016-01-15 13:00:58 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-01-15 16:30:00 +0000
commite024aab39cc75d8c0c6068bae07dfb0e758e7157 (patch)
tree45b3619d9b71f213064cfca396984033153f376c /bitbake/lib/toaster/toastergui/tables.py
parentfcb20f9dfd076f7d35f2a1b7b6767eb4033897c2 (diff)
downloadpoky-e024aab39cc75d8c0c6068bae07dfb0e758e7157.tar.gz
bitbake: toastergui: streamline construction of filter objects
In line with comments from review, remove the QuerysetFilter class (redundant) and convert ProjectFilters into a class with static methods. [YOCTO #8738] (Bitbake rev: 59379bf6467029223045c5ebef868729d8e02c86) Signed-off-by: Elliot Smith <elliot.smith@intel.com> Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/toaster/toastergui/tables.py')
-rw-r--r--bitbake/lib/toaster/toastergui/tables.py35
1 files changed, 17 insertions, 18 deletions
diff --git a/bitbake/lib/toaster/toastergui/tables.py b/bitbake/lib/toaster/toastergui/tables.py
index d0ed49625d..b7d977ea03 100644
--- a/bitbake/lib/toaster/toastergui/tables.py
+++ b/bitbake/lib/toaster/toastergui/tables.py
@@ -20,7 +20,6 @@
20# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 21
22from toastergui.widgets import ToasterTable 22from toastergui.widgets import ToasterTable
23from toastergui.querysetfilter import QuerysetFilter
24from orm.models import Recipe, ProjectLayer, Layer_Version, Machine, Project 23from orm.models import Recipe, ProjectLayer, Layer_Version, Machine, Project
25from orm.models import CustomImageRecipe, Package, Build, LogMessage, Task 24from orm.models import CustomImageRecipe, Package, Build, LogMessage, Task
26from orm.models import ProjectTarget 25from orm.models import ProjectTarget
@@ -37,9 +36,13 @@ from toastergui.tablefilter import TableFilterActionDateRange
37from toastergui.tablefilter import TableFilterActionDay 36from toastergui.tablefilter import TableFilterActionDay
38 37
39class ProjectFilters(object): 38class ProjectFilters(object):
40 def __init__(self, project_layers): 39 @staticmethod
41 self.in_project = QuerysetFilter(Q(layer_version__in=project_layers)) 40 def in_project(project_layers):
42 self.not_in_project = QuerysetFilter(~Q(layer_version__in=project_layers)) 41 return Q(layer_version__in=project_layers)
42
43 @staticmethod
44 def not_in_project(project_layers):
45 return ~(ProjectFilters.in_project(project_layers))
43 46
44class LayersTable(ToasterTable): 47class LayersTable(ToasterTable):
45 """Table of layers in Toaster""" 48 """Table of layers in Toaster"""
@@ -71,13 +74,13 @@ class LayersTable(ToasterTable):
71 in_project_action = TableFilterActionToggle( 74 in_project_action = TableFilterActionToggle(
72 "in_project", 75 "in_project",
73 "Layers added to this project", 76 "Layers added to this project",
74 QuerysetFilter(criteria) 77 criteria
75 ) 78 )
76 79
77 not_in_project_action = TableFilterActionToggle( 80 not_in_project_action = TableFilterActionToggle(
78 "not_in_project", 81 "not_in_project",
79 "Layers not added to this project", 82 "Layers not added to this project",
80 QuerysetFilter(~criteria) 83 ~criteria
81 ) 84 )
82 85
83 in_current_project_filter.add_action(in_project_action) 86 in_current_project_filter.add_action(in_project_action)
@@ -217,8 +220,6 @@ class MachinesTable(ToasterTable):
217 def setup_filters(self, *args, **kwargs): 220 def setup_filters(self, *args, **kwargs):
218 project = Project.objects.get(pk=kwargs['pid']) 221 project = Project.objects.get(pk=kwargs['pid'])
219 222
220 project_filters = ProjectFilters(self.project_layers)
221
222 in_current_project_filter = TableFilter( 223 in_current_project_filter = TableFilter(
223 "in_current_project", 224 "in_current_project",
224 "Filter by project machines" 225 "Filter by project machines"
@@ -227,13 +228,13 @@ class MachinesTable(ToasterTable):
227 in_project_action = TableFilterActionToggle( 228 in_project_action = TableFilterActionToggle(
228 "in_project", 229 "in_project",
229 "Machines provided by layers added to this project", 230 "Machines provided by layers added to this project",
230 project_filters.in_project 231 ProjectFilters.in_project(self.project_layers)
231 ) 232 )
232 233
233 not_in_project_action = TableFilterActionToggle( 234 not_in_project_action = TableFilterActionToggle(
234 "not_in_project", 235 "not_in_project",
235 "Machines provided by layers not added to this project", 236 "Machines provided by layers not added to this project",
236 project_filters.not_in_project 237 ProjectFilters.not_in_project(self.project_layers)
237 ) 238 )
238 239
239 in_current_project_filter.add_action(in_project_action) 240 in_current_project_filter.add_action(in_project_action)
@@ -350,8 +351,6 @@ class RecipesTable(ToasterTable):
350 return context 351 return context
351 352
352 def setup_filters(self, *args, **kwargs): 353 def setup_filters(self, *args, **kwargs):
353 project_filters = ProjectFilters(self.project_layers)
354
355 table_filter = TableFilter( 354 table_filter = TableFilter(
356 'in_current_project', 355 'in_current_project',
357 'Filter by project recipes' 356 'Filter by project recipes'
@@ -360,13 +359,13 @@ class RecipesTable(ToasterTable):
360 in_project_action = TableFilterActionToggle( 359 in_project_action = TableFilterActionToggle(
361 'in_project', 360 'in_project',
362 'Recipes provided by layers added to this project', 361 'Recipes provided by layers added to this project',
363 project_filters.in_project 362 ProjectFilters.in_project(self.project_layers)
364 ) 363 )
365 364
366 not_in_project_action = TableFilterActionToggle( 365 not_in_project_action = TableFilterActionToggle(
367 'not_in_project', 366 'not_in_project',
368 'Recipes provided by layers not added to this project', 367 'Recipes provided by layers not added to this project',
369 project_filters.not_in_project 368 ProjectFilters.not_in_project(self.project_layers)
370 ) 369 )
371 370
372 table_filter.add_action(in_project_action) 371 table_filter.add_action(in_project_action)
@@ -1140,13 +1139,13 @@ class BuildsTable(ToasterTable):
1140 successful_builds_action = TableFilterActionToggle( 1139 successful_builds_action = TableFilterActionToggle(
1141 'successful_builds', 1140 'successful_builds',
1142 'Successful builds', 1141 'Successful builds',
1143 QuerysetFilter(Q(outcome=Build.SUCCEEDED)) 1142 Q(outcome=Build.SUCCEEDED)
1144 ) 1143 )
1145 1144
1146 failed_builds_action = TableFilterActionToggle( 1145 failed_builds_action = TableFilterActionToggle(
1147 'failed_builds', 1146 'failed_builds',
1148 'Failed builds', 1147 'Failed builds',
1149 QuerysetFilter(Q(outcome=Build.FAILED)) 1148 Q(outcome=Build.FAILED)
1150 ) 1149 )
1151 1150
1152 outcome_filter.add_action(successful_builds_action) 1151 outcome_filter.add_action(successful_builds_action)
@@ -1226,13 +1225,13 @@ class BuildsTable(ToasterTable):
1226 with_failed_tasks_action = TableFilterActionToggle( 1225 with_failed_tasks_action = TableFilterActionToggle(
1227 'with_failed_tasks', 1226 'with_failed_tasks',
1228 'Builds with failed tasks', 1227 'Builds with failed tasks',
1229 QuerysetFilter(criteria) 1228 criteria
1230 ) 1229 )
1231 1230
1232 without_failed_tasks_action = TableFilterActionToggle( 1231 without_failed_tasks_action = TableFilterActionToggle(
1233 'without_failed_tasks', 1232 'without_failed_tasks',
1234 'Builds without failed tasks', 1233 'Builds without failed tasks',
1235 QuerysetFilter(~criteria) 1234 ~criteria
1236 ) 1235 )
1237 1236
1238 failed_tasks_filter.add_action(with_failed_tasks_action) 1237 failed_tasks_filter.add_action(with_failed_tasks_action)