diff options
Diffstat (limited to 'bitbake')
-rw-r--r-- | bitbake/lib/toaster/orm/models.py | 49 | ||||
-rw-r--r-- | bitbake/lib/toaster/toastergui/tables.py | 2 | ||||
-rw-r--r-- | bitbake/lib/toaster/toastergui/typeaheads.py | 5 |
3 files changed, 34 insertions, 22 deletions
diff --git a/bitbake/lib/toaster/orm/models.py b/bitbake/lib/toaster/orm/models.py index 9a052bf7a0..5aed158c12 100644 --- a/bitbake/lib/toaster/orm/models.py +++ b/bitbake/lib/toaster/orm/models.py | |||
@@ -191,6 +191,7 @@ class Project(models.Model): | |||
191 | 191 | ||
192 | # returns a queryset of compatible layers for a project | 192 | # returns a queryset of compatible layers for a project |
193 | def compatible_layerversions(self, release = None, layer_name = None): | 193 | def compatible_layerversions(self, release = None, layer_name = None): |
194 | logger.warning("This function is deprecated") | ||
194 | if release == None: | 195 | if release == None: |
195 | release = self.release | 196 | release = self.release |
196 | # layers on the same branch or layers specifically set for this project | 197 | # layers on the same branch or layers specifically set for this project |
@@ -205,45 +206,55 @@ class Project(models.Model): | |||
205 | 206 | ||
206 | return queryset | 207 | return queryset |
207 | 208 | ||
208 | def projectlayer_equivalent_set(self): | 209 | def get_all_compatible_layer_versions(self): |
209 | return self.compatible_layerversions().filter(layer__name__in = [x.layercommit.layer.name for x in self.projectlayer_set.all()]).select_related("up_branch") | 210 | """ Returns Queryset of all Layer_Versions which are compatible with |
211 | this project""" | ||
212 | queryset = Layer_Version.objects.filter( | ||
213 | (Q(up_branch__name=self.release.branch_name) & Q(build=None)) | ||
214 | | Q(project=self)) | ||
215 | |||
216 | return queryset | ||
217 | |||
218 | def get_project_layer_versions(self, pk=False): | ||
219 | """ Returns the Layer_Versions currently added to this project """ | ||
220 | layer_versions = self.projectlayer_set.all().values('layercommit') | ||
221 | |||
222 | if pk is False: | ||
223 | return layer_versions | ||
224 | else: | ||
225 | return layer_versions.values_list('pk', flat=True) | ||
226 | |||
210 | 227 | ||
211 | def get_available_machines(self): | 228 | def get_available_machines(self): |
212 | """ Returns QuerySet of all Machines which are provided by the | 229 | """ Returns QuerySet of all Machines which are provided by the |
213 | Layers currently added to the Project """ | 230 | Layers currently added to the Project """ |
214 | queryset = Machine.objects.filter(layer_version__in=self.projectlayer_equivalent_set) | 231 | queryset = Machine.objects.filter( |
232 | layer_version__in=self.get_project_layer_versions(self)) | ||
233 | |||
215 | return queryset | 234 | return queryset |
216 | 235 | ||
217 | def get_all_compatible_machines(self): | 236 | def get_all_compatible_machines(self): |
218 | """ Returns QuerySet of all the compatible machines available to the | 237 | """ Returns QuerySet of all the compatible machines available to the |
219 | project including ones from Layers not currently added """ | 238 | project including ones from Layers not currently added """ |
220 | compatible_layers = self.compatible_layerversions() | 239 | queryset = Machine.objects.filter( |
240 | layer_version__in=self.get_all_compatible_layer_versions()) | ||
221 | 241 | ||
222 | queryset = Machine.objects.filter(layer_version__in=compatible_layers) | ||
223 | return queryset | 242 | return queryset |
224 | 243 | ||
225 | def get_available_recipes(self): | 244 | def get_available_recipes(self): |
226 | """ Returns QuerySet of all Recipes which are provided by the Layers | 245 | """ Returns QuerySet of all the recipes that are provided by layers |
227 | currently added to the Project """ | 246 | added to this project """ |
228 | project_layers = self.projectlayer_equivalent_set() | 247 | queryset = Recipe.objects.filter( |
229 | queryset = Recipe.objects.filter(layer_version__in = project_layers) | 248 | layer_version__in=self.get_project_layer_versions()) |
230 | |||
231 | # Copied from get_all_compatible_recipes | ||
232 | search_maxids = map(lambda i: i[0], list(queryset.values('name').distinct().annotate(max_id=Max('id')).values_list('max_id'))) | ||
233 | queryset = queryset.filter(id__in=search_maxids).select_related('layer_version', 'layer_version__layer', 'layer_version__up_branch', 'layer_source') | ||
234 | # End copy | ||
235 | 249 | ||
236 | return queryset | 250 | return queryset |
237 | 251 | ||
238 | def get_all_compatible_recipes(self): | 252 | def get_all_compatible_recipes(self): |
239 | """ Returns QuerySet of all the compatible Recipes available to the | 253 | """ Returns QuerySet of all the compatible Recipes available to the |
240 | project including ones from Layers not currently added """ | 254 | project including ones from Layers not currently added """ |
241 | compatible_layerversions = self.compatible_layerversions() | 255 | queryset = Recipe.objects.filter( |
242 | queryset = Recipe.objects.filter(layer_version__in = compatible_layerversions) | 256 | layer_version__in=self.get_all_compatible_layer_versions()) |
243 | |||
244 | search_maxids = map(lambda i: i[0], list(queryset.values('name').distinct().annotate(max_id=Max('id')).values_list('max_id'))) | ||
245 | 257 | ||
246 | queryset = queryset.filter(id__in=search_maxids).select_related('layer_version', 'layer_version__layer', 'layer_version__up_branch', 'layer_source') | ||
247 | return queryset | 258 | return queryset |
248 | 259 | ||
249 | 260 | ||
diff --git a/bitbake/lib/toaster/toastergui/tables.py b/bitbake/lib/toaster/toastergui/tables.py index 3354072e13..5cc04a2372 100644 --- a/bitbake/lib/toaster/toastergui/tables.py +++ b/bitbake/lib/toaster/toastergui/tables.py | |||
@@ -221,7 +221,7 @@ class MachinesTable(ToasterTable, ProjectFiltersMixin): | |||
221 | 221 | ||
222 | def setup_filters(self, *args, **kwargs): | 222 | def setup_filters(self, *args, **kwargs): |
223 | project = Project.objects.get(pk=kwargs['pid']) | 223 | project = Project.objects.get(pk=kwargs['pid']) |
224 | self.project_layers = project.projectlayer_equivalent_set() | 224 | self.project_layers = project.get_project_layer_versions() |
225 | 225 | ||
226 | self.add_filter(title="Filter by project machines", | 226 | self.add_filter(title="Filter by project machines", |
227 | name="in_current_project", | 227 | name="in_current_project", |
diff --git a/bitbake/lib/toaster/toastergui/typeaheads.py b/bitbake/lib/toaster/toastergui/typeaheads.py index d5bec58ea7..9db31827ba 100644 --- a/bitbake/lib/toaster/toastergui/typeaheads.py +++ b/bitbake/lib/toaster/toastergui/typeaheads.py | |||
@@ -27,7 +27,7 @@ class LayersTypeAhead(ToasterTypeAhead): | |||
27 | super(LayersTypeAhead, self).__init__() | 27 | super(LayersTypeAhead, self).__init__() |
28 | 28 | ||
29 | def apply_search(self, search_term, prj, request): | 29 | def apply_search(self, search_term, prj, request): |
30 | layers = prj.compatible_layerversions() | 30 | layers = prj.get_all_compatible_layer_versions() |
31 | layers = layers.order_by('layer__name') | 31 | layers = layers.order_by('layer__name') |
32 | 32 | ||
33 | # Unlike the other typeaheads we also don't want to show suggestions | 33 | # Unlike the other typeaheads we also don't want to show suggestions |
@@ -35,7 +35,8 @@ class LayersTypeAhead(ToasterTypeAhead): | |||
35 | # layerdeps to a new layer. | 35 | # layerdeps to a new layer. |
36 | if ("include_added" in request.GET and | 36 | if ("include_added" in request.GET and |
37 | request.GET['include_added'] != "true"): | 37 | request.GET['include_added'] != "true"): |
38 | layers = layers.exclude(pk__in=prj.projectlayer_equivalent_set) | 38 | layers = layers.exclude( |
39 | pk__in=prj.get_project_layer_versions(pk=True)) | ||
39 | 40 | ||
40 | primary_results = layers.filter(layer__name__istartswith=search_term) | 41 | primary_results = layers.filter(layer__name__istartswith=search_term) |
41 | secondary_results = layers.filter(layer__name__icontains=search_term).exclude(pk__in=primary_results) | 42 | secondary_results = layers.filter(layer__name__icontains=search_term).exclude(pk__in=primary_results) |