aboutsummaryrefslogtreecommitdiffstats
path: root/layerindex/views.py
diff options
context:
space:
mode:
authorPaul Eggleton <paul.eggleton@linux.intel.com>2014-03-09 18:59:33 +0000
committerPaul Eggleton <paul.eggleton@linux.intel.com>2014-03-09 19:17:49 +0000
commit6d0b9d40aa0cc25159a8ab8a717e69b15cf9661c (patch)
tree1e1f906b5be59f725eee6e6c30a5652f0e4ac309 /layerindex/views.py
parent7f990bc0854c1a6073ae166c8448672080f82cbd (diff)
downloadopenembedded-core-contrib-6d0b9d40aa0cc25159a8ab8a717e69b15cf9661c.tar.gz
duplicates: add ability to select layers
Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
Diffstat (limited to 'layerindex/views.py')
-rw-r--r--layerindex/views.py15
1 files changed, 11 insertions, 4 deletions
diff --git a/layerindex/views.py b/layerindex/views.py
index ac77c52ed0..0db1e7cfaf 100644
--- a/layerindex/views.py
+++ b/layerindex/views.py
@@ -394,24 +394,31 @@ class RecipeSearchView(ListView):
return context
class DuplicatesView(TemplateView):
- def get_recipes(self):
+ def get_recipes(self, layer_ids):
init_qs = Recipe.objects.filter(layerbranch__branch__name=self.kwargs['branch'])
+ if layer_ids:
+ init_qs = init_qs.filter(layerbranch__layer__in=layer_ids)
dupes = init_qs.values('pn').annotate(Count('layerbranch', distinct=True)).filter(layerbranch__count__gt=1)
qs = init_qs.all().filter(pn__in=[item['pn'] for item in dupes]).order_by('pn', 'layerbranch__layer')
return recipes_preferred_count(qs)
- def get_classes(self):
+ def get_classes(self, layer_ids):
init_qs = BBClass.objects.filter(layerbranch__branch__name=self.kwargs['branch'])
+ if layer_ids:
+ init_qs = init_qs.filter(layerbranch__layer__in=layer_ids)
dupes = init_qs.values('name').annotate(Count('layerbranch', distinct=True)).filter(layerbranch__count__gt=1)
qs = init_qs.all().filter(name__in=[item['name'] for item in dupes]).order_by('name', 'layerbranch__layer')
return qs
def get_context_data(self, **kwargs):
+ layer_ids = [int(i) for i in self.request.GET.getlist('l')]
context = super(DuplicatesView, self).get_context_data(**kwargs)
- context['recipes'] = self.get_recipes()
- context['classes'] = self.get_classes()
+ context['recipes'] = self.get_recipes(layer_ids)
+ context['classes'] = self.get_classes(layer_ids)
context['url_branch'] = self.kwargs['branch']
context['this_url_name'] = resolve(self.request.path_info).url_name
+ context['layers'] = LayerBranch.objects.filter(branch__name=self.kwargs['branch']).filter(layer__status='P').order_by( 'layer__name')
+ context['showlayers'] = layer_ids
return context
class AdvancedRecipeSearchView(ListView):