diff options
author | Michael Wood <michael.g.wood@intel.com> | 2016-12-09 16:52:48 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2016-12-12 20:44:54 +0000 |
commit | 4ecd040f3bdbbe000e0a154cf500babd7b916396 (patch) | |
tree | 74204a0abb7ffcfb0d9975a95d59fded0aa5390e /bitbake | |
parent | 8eed2641636791574d35a9d3a445ee55c7b2258d (diff) | |
download | poky-4ecd040f3bdbbe000e0a154cf500babd7b916396.tar.gz |
bitbake: toaster: typeaheads widgets Fix flake8 issues and remove redundant code
Fix flake8 issues and remove redundant __init__ function definitions
from typeaheads (likely a copy and paste error).
(Bitbake rev: be1f9f48da480d813e3364815cb3e002ba70dd22)
Signed-off-by: Michael Wood <michael.g.wood@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake')
-rw-r--r-- | bitbake/lib/toaster/toastergui/typeaheads.py | 80 | ||||
-rw-r--r-- | bitbake/lib/toaster/toastergui/widgets.py | 8 |
2 files changed, 45 insertions, 43 deletions
diff --git a/bitbake/lib/toaster/toastergui/typeaheads.py b/bitbake/lib/toaster/toastergui/typeaheads.py index 4ded9ac2e6..2c6c1454a1 100644 --- a/bitbake/lib/toaster/toastergui/typeaheads.py +++ b/bitbake/lib/toaster/toastergui/typeaheads.py | |||
@@ -23,8 +23,6 @@ from django.core.urlresolvers import reverse | |||
23 | class LayersTypeAhead(ToasterTypeAhead): | 23 | class LayersTypeAhead(ToasterTypeAhead): |
24 | """ Typeahead for layers available and not added in the current project's | 24 | """ Typeahead for layers available and not added in the current project's |
25 | configuration """ | 25 | configuration """ |
26 | def __init__(self): | ||
27 | super(LayersTypeAhead, self).__init__() | ||
28 | 26 | ||
29 | def apply_search(self, search_term, prj, request): | 27 | def apply_search(self, search_term, prj, request): |
30 | layers = prj.get_all_compatible_layer_versions() | 28 | layers = prj.get_all_compatible_layer_versions() |
@@ -33,13 +31,15 @@ class LayersTypeAhead(ToasterTypeAhead): | |||
33 | # Unlike the other typeaheads we also don't want to show suggestions | 31 | # Unlike the other typeaheads we also don't want to show suggestions |
34 | # for layers already in the project unless required such as when adding | 32 | # for layers already in the project unless required such as when adding |
35 | # layerdeps to a new layer. | 33 | # layerdeps to a new layer. |
36 | if ("include_added" in request.GET and | 34 | if "include_added" in request.GET and \ |
37 | request.GET['include_added'] != "true"): | 35 | request.GET['include_added'] != "true": |
38 | layers = layers.exclude( | 36 | layers = layers.exclude( |
39 | pk__in=prj.get_project_layer_versions(pk=True)) | 37 | pk__in=prj.get_project_layer_versions(pk=True)) |
40 | 38 | ||
41 | primary_results = layers.filter(layer__name__istartswith=search_term) | 39 | primary_results = layers.filter(layer__name__istartswith=search_term) |
42 | secondary_results = layers.filter(layer__name__icontains=search_term).exclude(pk__in=primary_results) | 40 | secondary_results = layers.filter( |
41 | layer__name__icontains=search_term).exclude( | ||
42 | pk__in=primary_results) | ||
43 | 43 | ||
44 | results = [] | 44 | results = [] |
45 | 45 | ||
@@ -49,97 +49,99 @@ class LayersTypeAhead(ToasterTypeAhead): | |||
49 | detail = "[ %s | %s ]" % (layer_version.layer.vcs_url, | 49 | detail = "[ %s | %s ]" % (layer_version.layer.vcs_url, |
50 | vcs_reference) | 50 | vcs_reference) |
51 | needed_fields = { | 51 | needed_fields = { |
52 | 'id' : layer_version.pk, | 52 | 'id': layer_version.pk, |
53 | 'name' : layer_version.layer.name, | 53 | 'name': layer_version.layer.name, |
54 | 'layerdetailurl' : layer_version.get_detailspage_url(prj.pk), | 54 | 'layerdetailurl': layer_version.get_detailspage_url(prj.pk), |
55 | 'vcs_url' : layer_version.layer.vcs_url, | 55 | 'vcs_url': layer_version.layer.vcs_url, |
56 | 'vcs_reference' : vcs_reference, | 56 | 'vcs_reference': vcs_reference, |
57 | 'detail' : detail, | 57 | 'detail': detail, |
58 | 'local_source_dir' : layer_version.layer.local_source_dir, | 58 | 'local_source_dir': layer_version.layer.local_source_dir, |
59 | } | 59 | } |
60 | 60 | ||
61 | results.append(needed_fields) | 61 | results.append(needed_fields) |
62 | 62 | ||
63 | return results | 63 | return results |
64 | 64 | ||
65 | |||
65 | class MachinesTypeAhead(ToasterTypeAhead): | 66 | class MachinesTypeAhead(ToasterTypeAhead): |
66 | """ Typeahead for all the machines available in the current project's | 67 | """ Typeahead for all the machines available in the current project's |
67 | configuration """ | 68 | configuration """ |
68 | def __init__(self): | ||
69 | super(MachinesTypeAhead, self).__init__() | ||
70 | 69 | ||
71 | def apply_search(self, search_term, prj, request): | 70 | def apply_search(self, search_term, prj, request): |
72 | machines = prj.get_available_machines() | 71 | machines = prj.get_available_machines() |
73 | machines = machines.order_by("name") | 72 | machines = machines.order_by("name") |
74 | 73 | ||
75 | primary_results = machines.filter(name__istartswith=search_term) | 74 | primary_results = machines.filter(name__istartswith=search_term) |
76 | secondary_results = machines.filter(name__icontains=search_term).exclude(pk__in=primary_results) | 75 | secondary_results = machines.filter( |
77 | tertiary_results = machines.filter(layer_version__layer__name__icontains=search_term).exclude(pk__in=primary_results).exclude(pk__in=secondary_results) | 76 | name__icontains=search_term).exclude(pk__in=primary_results) |
77 | tertiary_results = machines.filter( | ||
78 | layer_version__layer__name__icontains=search_term).exclude( | ||
79 | pk__in=primary_results).exclude(pk__in=secondary_results) | ||
78 | 80 | ||
79 | results = [] | 81 | results = [] |
80 | 82 | ||
81 | for machine in list(primary_results) + list(secondary_results) + list(tertiary_results): | 83 | for machine in list(primary_results) + list(secondary_results) + \ |
84 | list(tertiary_results): | ||
82 | 85 | ||
83 | detail = "[ %s ]" % (machine.layer_version.layer.name) | 86 | detail = "[ %s ]" % (machine.layer_version.layer.name) |
84 | needed_fields = { | 87 | needed_fields = { |
85 | 'id' : machine.pk, | 88 | 'id': machine.pk, |
86 | 'name' : machine.name, | 89 | 'name': machine.name, |
87 | 'detail' : detail, | 90 | 'detail': detail, |
88 | } | 91 | } |
89 | 92 | ||
90 | results.append(needed_fields) | 93 | results.append(needed_fields) |
91 | |||
92 | return results | 94 | return results |
93 | 95 | ||
96 | |||
94 | class RecipesTypeAhead(ToasterTypeAhead): | 97 | class RecipesTypeAhead(ToasterTypeAhead): |
95 | """ Typeahead for all the recipes available in the current project's | 98 | """ Typeahead for all the recipes available in the current project's |
96 | configuration """ | 99 | configuration """ |
97 | def __init__(self): | ||
98 | super(RecipesTypeAhead, self).__init__() | ||
99 | |||
100 | def apply_search(self, search_term, prj, request): | 100 | def apply_search(self, search_term, prj, request): |
101 | recipes = prj.get_available_recipes() | 101 | recipes = prj.get_available_recipes() |
102 | recipes = recipes.order_by("name") | 102 | recipes = recipes.order_by("name") |
103 | 103 | ||
104 | |||
105 | primary_results = recipes.filter(name__istartswith=search_term) | 104 | primary_results = recipes.filter(name__istartswith=search_term) |
106 | secondary_results = recipes.filter(name__icontains=search_term).exclude(pk__in=primary_results) | 105 | secondary_results = recipes.filter( |
107 | tertiary_results = recipes.filter(layer_version__layer__name__icontains=search_term).exclude(pk__in=primary_results).exclude(pk__in=secondary_results) | 106 | name__icontains=search_term).exclude(pk__in=primary_results) |
107 | tertiary_results = recipes.filter( | ||
108 | layer_version__layer__name__icontains=search_term).exclude( | ||
109 | pk__in=primary_results).exclude(pk__in=secondary_results) | ||
108 | 110 | ||
109 | results = [] | 111 | results = [] |
110 | 112 | ||
111 | for recipe in list(primary_results) + list(secondary_results) + list(tertiary_results): | 113 | for recipe in list(primary_results) + list(secondary_results) + \ |
114 | list(tertiary_results): | ||
112 | 115 | ||
113 | detail = "[ %s ]" % (recipe.layer_version.layer.name) | 116 | detail = "[ %s ]" % (recipe.layer_version.layer.name) |
114 | needed_fields = { | 117 | needed_fields = { |
115 | 'id' : recipe.pk, | 118 | 'id': recipe.pk, |
116 | 'name' : recipe.name, | 119 | 'name': recipe.name, |
117 | 'detail' : detail, | 120 | 'detail': detail, |
118 | } | 121 | } |
119 | 122 | ||
120 | results.append(needed_fields) | 123 | results.append(needed_fields) |
121 | 124 | ||
122 | return results | 125 | return results |
123 | 126 | ||
127 | |||
124 | class ProjectsTypeAhead(ToasterTypeAhead): | 128 | class ProjectsTypeAhead(ToasterTypeAhead): |
125 | """ Typeahead for all the projects, except for command line builds """ | 129 | """ Typeahead for all the projects, except for command line builds """ |
126 | def __init__(self): | ||
127 | super(ProjectsTypeAhead, self).__init__() | ||
128 | |||
129 | def apply_search(self, search_term, prj, request): | 130 | def apply_search(self, search_term, prj, request): |
130 | projects = Project.objects.exclude(is_default=True).order_by("name") | 131 | projects = Project.objects.exclude(is_default=True).order_by("name") |
131 | 132 | ||
132 | primary_results = projects.filter(name__istartswith=search_term) | 133 | primary_results = projects.filter(name__istartswith=search_term) |
133 | secondary_results = projects.filter(name__icontains=search_term).exclude(pk__in=primary_results) | 134 | secondary_results = projects.filter( |
135 | name__icontains=search_term).exclude(pk__in=primary_results) | ||
134 | 136 | ||
135 | results = [] | 137 | results = [] |
136 | 138 | ||
137 | for project in list(primary_results) + list(secondary_results): | 139 | for project in list(primary_results) + list(secondary_results): |
138 | needed_fields = { | 140 | needed_fields = { |
139 | 'id' : project.pk, | 141 | 'id': project.pk, |
140 | 'name' : project.name, | 142 | 'name': project.name, |
141 | 'detail' : "", | 143 | 'detail': "", |
142 | 'projectPageUrl' : reverse('project', args=(project.pk,)) | 144 | 'projectPageUrl': reverse('project', args=(project.pk,)) |
143 | } | 145 | } |
144 | 146 | ||
145 | results.append(needed_fields) | 147 | results.append(needed_fields) |
diff --git a/bitbake/lib/toaster/toastergui/widgets.py b/bitbake/lib/toaster/toastergui/widgets.py index 026903d35d..6b7b981f3b 100644 --- a/bitbake/lib/toaster/toastergui/widgets.py +++ b/bitbake/lib/toaster/toastergui/widgets.py | |||
@@ -42,6 +42,8 @@ import json | |||
42 | import collections | 42 | import collections |
43 | import re | 43 | import re |
44 | 44 | ||
45 | from toastergui.tablefilter import TableFilterMap | ||
46 | |||
45 | try: | 47 | try: |
46 | from urllib import unquote_plus | 48 | from urllib import unquote_plus |
47 | except ImportError: | 49 | except ImportError: |
@@ -50,8 +52,6 @@ except ImportError: | |||
50 | import logging | 52 | import logging |
51 | logger = logging.getLogger("toaster") | 53 | logger = logging.getLogger("toaster") |
52 | 54 | ||
53 | from toastergui.tablefilter import TableFilterMap | ||
54 | |||
55 | 55 | ||
56 | class NoFieldOrDataName(Exception): | 56 | class NoFieldOrDataName(Exception): |
57 | pass | 57 | pass |
@@ -259,9 +259,9 @@ class ToasterTable(TemplateView): | |||
259 | queries = query | 259 | queries = query |
260 | 260 | ||
261 | if search_queries: | 261 | if search_queries: |
262 | search_queries &= queries | 262 | search_queries &= queries |
263 | else: | 263 | else: |
264 | search_queries = queries | 264 | search_queries = queries |
265 | 265 | ||
266 | self.queryset = self.queryset.filter(search_queries) | 266 | self.queryset = self.queryset.filter(search_queries) |
267 | 267 | ||