diff options
author | Liam R. Howlett <Liam.Howlett@WindRiver.com> | 2016-10-04 14:00:20 -0400 |
---|---|---|
committer | Paul Eggleton <paul.eggleton@linux.intel.com> | 2016-10-18 16:42:15 +1300 |
commit | 31c85196d05392726afaed622b46b13210e5912b (patch) | |
tree | 5cc4f950ff2f41f535f7eceef913765c1221c12c /layerindex/views.py | |
parent | 4f0be8a7d03124aa834431e301a2f54abf05cd61 (diff) | |
download | openembedded-core-contrib-31c85196d05392726afaed622b46b13210e5912b.tar.gz |
layerindex: Add distro to web interface and model
Add the distros to the index. This looks a lot like the machines
and allows users to search for a particular distro.
Signed-off-by: Liam R. Howlett <Liam.Howlett@WindRiver.com>
Added associated migration.
Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
Diffstat (limited to 'layerindex/views.py')
-rw-r--r-- | layerindex/views.py | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/layerindex/views.py b/layerindex/views.py index 3f9525d725..06045ae6a7 100644 --- a/layerindex/views.py +++ b/layerindex/views.py @@ -10,7 +10,7 @@ from django.http import HttpResponse, HttpResponseRedirect, HttpResponseForbidde from django.core.urlresolvers import reverse, reverse_lazy, resolve from django.core.exceptions import PermissionDenied from django.template import RequestContext -from layerindex.models import Branch, LayerItem, LayerMaintainer, LayerBranch, LayerDependency, LayerNote, Recipe, Machine, BBClass, BBAppend, RecipeChange, RecipeChangeset, ClassicRecipe +from layerindex.models import Branch, LayerItem, LayerMaintainer, LayerBranch, LayerDependency, LayerNote, Recipe, Machine, Distro, BBClass, BBAppend, RecipeChange, RecipeChangeset, ClassicRecipe from datetime import datetime from itertools import chain from django.views.generic import TemplateView, DetailView, ListView @@ -326,6 +326,7 @@ class LayerDetailView(DetailView): if layerbranch: context['layerbranch'] = layerbranch context['machines'] = layerbranch.machine_set.order_by('name') + context['distros'] = layerbranch.distro_set.order_by('name') context['appends'] = layerbranch.bbappend_set.order_by('filename') context['classes'] = layerbranch.bbclass_set.order_by('name') context['url_branch'] = self.kwargs['branch'] @@ -596,6 +597,32 @@ class MachineSearchView(ListView): return context +class DistroSearchView(ListView): + context_object_name = 'distro_list' + paginate_by = 50 + + def get_queryset(self): + _check_url_branch(self.kwargs) + query_string = self.request.GET.get('q', '') + init_qs = Distro.objects.filter(layerbranch__branch__name=self.kwargs['branch']) + if query_string.strip(): + entry_query = simplesearch.get_query(query_string, ['name', 'description']) + return init_qs.filter(entry_query).order_by('name', 'layerbranch__layer') + + if 'q' in self.request.GET: + return init_qs.order_by('name', 'layerbranch__layer') + + # Be consistent with RecipeSearchView + return Distro.objects.none() + + def get_context_data(self, **kwargs): + context = super(DistroSearchView, self).get_context_data(**kwargs) + context['search_keyword'] = self.request.GET.get('q', '') + context['url_branch'] = self.kwargs['branch'] + context['this_url_name'] = resolve(self.request.path_info).url_name + return context + + class PlainTextListView(ListView): def render_to_response(self, context): "Returns a plain text response rendering of the template" |