[layerindex-web][patch v2 0/1]
v2 cover [layerindex-web][patch v2 0/1]
Reordered the classes and distro tabs to be consistent with the tabs on the layer detail pages.
The following changes since commit 44386eea41a8e1bb8a3ab831613cfc1a19ff6ecd:
querysethelper: fix searching (2017-10-31 09:58:30 +1300)
are available in the git repository at:
git://git.yoctoproject.org/layerindex-web abrindle/bbclass_search
http://git.yoctoproject.org/cgit.cgi/layerindex-web/log/?h=abrindle/bbclass_search
Amanda Brindle (1):
templates/layerindex/classes.html: Add bbclass search
layerindex/restviews.py | 10 ++++- layerindex/urls.py | 3 ++ layerindex/urls_branch.py | 6 ++- layerindex/views.py | 24 ++++++++++++ templates/layerindex/classes.html | 75 ++++++++++++++++++++++++++++++++++++++ templates/layerindex/distros.html | 1 + templates/layerindex/layers.html | 1 + templates/layerindex/machines.html | 1 + templates/layerindex/recipes.html | 1 + 9 files changed, 120 insertions(+), 2 deletions(-) create mode 100644 templates/layerindex/classes.html
Signature · 1 line
2.7.4
PATCH v2 1/1 templates/layerindex/classes.html: Add bbclass search
Add another tab to search for classes.
Fixes [YOCTO #11207]
Signed-off by: Amanda Brindle <[email protected]>
--- layerindex/restviews.py | 10 ++++- layerindex/urls.py | 3 ++ layerindex/urls_branch.py | 6 ++- layerindex/views.py | 24 ++++++++++++ templates/layerindex/classes.html | 75 ++++++++++++++++++++++++++++++++++++++ templates/layerindex/distros.html | 1 + templates/layerindex/layers.html | 1 + templates/layerindex/machines.html | 1 + templates/layerindex/recipes.html | 1 + 9 files changed, 120 insertions(+), 2 deletions(-) create mode 100644 templates/layerindex/classes.html
layerindex/restviews.py +9 -1
@@ -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
layerindex/urls.py +3 -0
@@ -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$',
layerindex/urls_branch.py +5 -1
@@ -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(
layerindex/views.py +24 -0
@@ -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):
templates/layerindex/classes.html new file +75 -0
75 lines not on this page · raw message
templates/layerindex/distros.html +1 -0
@@ -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 %}
templates/layerindex/layers.html +1 -0
@@ -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 %}
templates/layerindex/machines.html +1 -0
@@ -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 %}
templates/layerindex/recipes.html +1 -0
@@ -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 %}
Signature · 1 line
2.7.4