diff options
author | Amanda Brindle <amanda.r.brindle@intel.com> | 2017-11-06 14:22:17 -0800 |
---|---|---|
committer | Paul Eggleton <paul.eggleton@linux.intel.com> | 2017-11-07 16:54:46 +1300 |
commit | 78c2561181f07b1c39f1dc3516a9110a39d874f2 (patch) | |
tree | ba64538d4b2325f3c530534307eeca3e13d5ed38 | |
parent | 44386eea41a8e1bb8a3ab831613cfc1a19ff6ecd (diff) | |
download | openembedded-core-contrib-78c2561181f07b1c39f1dc3516a9110a39d874f2.tar.gz |
templates/layerindex/classes.html: Add bbclass search
Add another tab to search for classes.
Fixes [YOCTO #11207]
Signed-off by: Amanda Brindle <amanda.r.brindle@intel.com>
Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
-rw-r--r-- | TODO | 1 | ||||
-rw-r--r-- | layerindex/restviews.py | 10 | ||||
-rw-r--r-- | layerindex/urls.py | 3 | ||||
-rw-r--r-- | layerindex/urls_branch.py | 6 | ||||
-rw-r--r-- | layerindex/views.py | 24 | ||||
-rw-r--r-- | templates/layerindex/classes.html | 75 | ||||
-rw-r--r-- | templates/layerindex/distros.html | 1 | ||||
-rw-r--r-- | templates/layerindex/layers.html | 1 | ||||
-rw-r--r-- | templates/layerindex/machines.html | 1 | ||||
-rw-r--r-- | templates/layerindex/recipes.html | 1 |
10 files changed, 120 insertions, 3 deletions
@@ -17,7 +17,6 @@ Other * Add log in again link to logout page. * Collect interesting news (layer add/delete, recipe add/delete/upgrade) and provide RSS feed * "Split layer" tool for when a layer is split out of another? (Saves time adding records everywhere) -* Search for bbclasses? * All-branch search/results so you can see version availability of recipes in all branches at once? * Show OE-Classic search results in OE-Core search? (with appropriate disclaimers) * Display no-results found message when search does not return any results in layer search diff --git a/layerindex/restviews.py b/layerindex/restviews.py index d947bbfce5..836aa54011 100644 --- a/layerindex/restviews.py +++ b/layerindex/restviews.py @@ -1,4 +1,4 @@ -from layerindex.models import Branch, LayerItem, LayerNote, LayerBranch, LayerDependency, Recipe, Machine, Distro +from layerindex.models import Branch, LayerItem, LayerNote, LayerBranch, LayerDependency, Recipe, Machine, Distro, BBClass from rest_framework import viewsets, serializers from layerindex.querysethelper import params_to_queryset, get_search_tuple @@ -64,3 +64,11 @@ class DistroSerializer(serializers.ModelSerializer): class DistroViewSet(ParametricSearchableModelViewSet): queryset = Distro.objects.all() serializer_class = DistroSerializer + +class ClassSerializer(serializers.ModelSerializer): + class Meta: + model = BBClass + +class ClassViewSet(ParametricSearchableModelViewSet): + queryset = BBClass.objects.all() + serializer_class = ClassSerializer diff --git a/layerindex/urls.py b/layerindex/urls.py index b4535d2ddd..6a1cb6add8 100644 --- a/layerindex/urls.py +++ b/layerindex/urls.py @@ -22,6 +22,7 @@ router.register(r'layerDependencies', restviews.LayerDependencyViewSet) router.register(r'recipes', restviews.RecipeViewSet) router.register(r'machines', restviews.MachineViewSet) router.register(r'distros', restviews.DistroViewSet) +router.register(r'classes', restviews.ClassViewSet) urlpatterns = patterns('', url(r'^$', @@ -40,6 +41,8 @@ urlpatterns = patterns('', RedirectView.as_view(url=reverse_lazy('machine_search', args=('master',)), permanent=False)), url(r'^distros/$', RedirectView.as_view(url=reverse_lazy('distro_search', args=('master',)), permanent=False)), + url(r'^classes/$', + RedirectView.as_view(url=reverse_lazy('class_search', args=('master',)), permanent=False)), url(r'^submit/$', edit_layer_view, {'template_name': 'layerindex/submitlayer.html'}, name="submit_layer"), url(r'^submit/thanks$', diff --git a/layerindex/urls_branch.py b/layerindex/urls_branch.py index 89659d90ab..d4518969e1 100644 --- a/layerindex/urls_branch.py +++ b/layerindex/urls_branch.py @@ -7,7 +7,7 @@ from django.conf.urls import * from django.views.defaults import page_not_found from django.core.urlresolvers import reverse_lazy -from layerindex.views import LayerListView, RecipeSearchView, MachineSearchView, DistroSearchView, PlainTextListView, LayerDetailView, edit_layer_view, delete_layer_view, edit_layernote_view, delete_layernote_view, RedirectParamsView, DuplicatesView, LayerUpdateDetailView +from layerindex.views import LayerListView, RecipeSearchView, MachineSearchView, DistroSearchView, ClassSearchView, PlainTextListView, LayerDetailView, edit_layer_view, delete_layer_view, edit_layernote_view, delete_layernote_view, RedirectParamsView, DuplicatesView, LayerUpdateDetailView urlpatterns = patterns('', url(r'^$', @@ -32,6 +32,10 @@ urlpatterns = patterns('', DistroSearchView.as_view( template_name='layerindex/distros.html'), name='distro_search'), + url(r'^classes/$', + ClassSearchView.as_view( + template_name='layerindex/classes.html'), + name='class_search'), url(r'^edit/(?P<slug>[-\w]+)/$', edit_layer_view, {'template_name': 'layerindex/editlayer.html'}, name="edit_layer"), url(r'^duplicates/$', DuplicatesView.as_view( diff --git a/layerindex/views.py b/layerindex/views.py index 3b22067822..03d47f2f49 100644 --- a/layerindex/views.py +++ b/layerindex/views.py @@ -724,6 +724,30 @@ class DistroSearchView(ListView): context['this_url_name'] = resolve(self.request.path_info).url_name return context +class ClassSearchView(ListView): + context_object_name = 'class_list' + paginate_by = 50 + + def get_queryset(self): + _check_url_branch(self.kwargs) + query_string = self.request.GET.get('q', '') + init_qs = BBClass.objects.filter(layerbranch__branch__name=self.kwargs['branch']) + if query_string.strip(): + entry_query = simplesearch.get_query(query_string, ['name']) + 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(ClassSearchView, 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): diff --git a/templates/layerindex/classes.html b/templates/layerindex/classes.html new file mode 100644 index 0000000000..34ac5aa3d2 --- /dev/null +++ b/templates/layerindex/classes.html @@ -0,0 +1,75 @@ +{% extends "base_toplevel.html" %} +{% load i18n %} + +{% comment %} + + layerindex-web - class index page template + + Copyright (C) 2013, 2017 Intel Corporation + Copyright (C) 2016 Wind River Systems + Licensed under the MIT license, see COPYING.MIT for details + +{% endcomment %} + + +<!-- +{% block title_append %} - classes{% endblock %} +--> + +{% block navs %} +{% autoescape on %} + <li><a href="{% url 'layer_list' url_branch %}">Layers</a></li> + <li><a href="{% url 'recipe_search' url_branch %}">Recipes</a></li> + <li><a href="{% url 'machine_search' url_branch %}">Machines</a></li> + <li class="active"><a href="{% url 'class_search' url_branch %}">Classes</a></li> + <li><a href="{% url 'distro_search' url_branch %}">Distros</a></li> +{% endautoescape %} +{% endblock %} + + +{% block content_inner %} +{% autoescape on %} + + + <div class="row-fluid"> + <div class="input-append"> + <form id="filter-form" action="{% url 'class_search' url_branch %}" method="get"> + <input type="text" class="input-xxlarge" id="appendedInputButtons" placeholder="Search classes" name="q" value="{{ search_keyword }}" /> + <button class="btn" type="submit">search</button> + </form> + </div> + </div> + +{% if class_list %} + <table class="table table-striped table-bordered classestable"> + <thead> + <tr> + <th>Class Name</th> + <th>Layer</th> + </tr> + </thead> + + <tbody> + {% for class in class_list %} + <tr> + <td><a href="{{ class.vcs_web_url }}">{{ class.name }}</a></td> + <td><a href="{% url 'layer_item' url_branch class.layerbranch.layer.name %}">{{ class.layerbranch.layer.name }}</a></td> + </tr> + {% endfor %} + </tbody> + </table> + + {% if is_paginated %} + {% load pagination %} + {% pagination page_obj %} + {% endif %} +{% else %} + {% if search_keyword %} + <p>No matching classes in database.</p> + {% endif %} +{% endif %} + + +{% endautoescape %} + +{% endblock %} diff --git a/templates/layerindex/distros.html b/templates/layerindex/distros.html index 70855848e6..5b6995a5dd 100644 --- a/templates/layerindex/distros.html +++ b/templates/layerindex/distros.html @@ -21,6 +21,7 @@ <li><a href="{% url 'layer_list' url_branch %}">Layers</a></li> <li><a href="{% url 'recipe_search' url_branch %}">Recipes</a></li> <li><a href="{% url 'machine_search' url_branch %}">Machines</a></li> + <li><a href="{% url 'class_search' url_branch %}">Classes</a></li> <li class="active"><a href="{% url 'distro_search' url_branch %}">Distros</a></li> {% endautoescape %} {% endblock %} diff --git a/templates/layerindex/layers.html b/templates/layerindex/layers.html index f1a37034fa..11954e0158 100644 --- a/templates/layerindex/layers.html +++ b/templates/layerindex/layers.html @@ -21,6 +21,7 @@ <li class="active"><a href="{% url 'layer_list' url_branch %}">Layers</a></li> <li><a href="{% url 'recipe_search' url_branch %}">Recipes</a></li> <li><a href="{% url 'machine_search' url_branch %}">Machines</a></li> + <li><a href="{% url 'class_search' url_branch %}">Classes</a></li> <li><a href="{% url 'distro_search' url_branch %}">Distros</a></li> {% endautoescape %} {% endblock %} diff --git a/templates/layerindex/machines.html b/templates/layerindex/machines.html index 2a9f947321..c0c6f33b3b 100644 --- a/templates/layerindex/machines.html +++ b/templates/layerindex/machines.html @@ -20,6 +20,7 @@ <li><a href="{% url 'layer_list' url_branch %}">Layers</a></li> <li><a href="{% url 'recipe_search' url_branch %}">Recipes</a></li> <li class="active"><a href="{% url 'machine_search' url_branch %}">Machines</a></li> + <li><a href="{% url 'class_search' url_branch %}">Classes</a></li> <li><a href="{% url 'distro_search' url_branch %}">Distros</a></li> {% endautoescape %} {% endblock %} diff --git a/templates/layerindex/recipes.html b/templates/layerindex/recipes.html index 60a266756f..13227504dc 100644 --- a/templates/layerindex/recipes.html +++ b/templates/layerindex/recipes.html @@ -20,6 +20,7 @@ <li><a href="{% url 'layer_list' url_branch %}">Layers</a></li> <li class="active"><a href="{% url 'recipe_search' url_branch %}">Recipes</a></li> <li><a href="{% url 'machine_search' url_branch %}">Machines</a></li> + <li><a href="{% url 'class_search' url_branch %}">Classes</a></li> <li><a href="{% url 'distro_search' url_branch %}">Distros</a></li> {% endautoescape %} {% endblock %} |