Skip to contentSkip to conversation

[layerindex-web][patch v1 0/1]

PATCH Superseded Amanda Brindle 1 participant 2 messages Oct 31, 2017

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover [layerindex-web][patch v1 0/1]

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
#1 lore raw

PATCH 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
index d947bbf..836aa54 100644
@@ -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
index b4535d2..6a1cb6a 100644
@@ -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
index 89659d9..d451896 100644
@@ -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
index 3b22067..03d47f2 100644
@@ -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
index 7085584..ed17744 100644
@@ -22,6 +22,7 @@
                             <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 'distro_search' url_branch %}">Distros</a></li>
+                            <li><a href="{% url 'class_search' url_branch %}">Classes</a></li>
 {% endautoescape %}
 {% endblock %}
 
templates/layerindex/layers.html +1 -0
index f1a3703..11baccd 100644
@@ -22,6 +22,7 @@
                             <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 'distro_search' url_branch %}">Distros</a></li>
+                            <li><a href="{% url 'class_search' url_branch %}">Classes</a></li>
 {% endautoescape %}
 {% endblock %}
 
templates/layerindex/machines.html +1 -0
index 2a9f947..b5b1365 100644
@@ -21,6 +21,7 @@
                             <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 'distro_search' url_branch %}">Distros</a></li>
+                            <li><a href="{% url 'class_search' url_branch %}">Classes</a></li>
 {% endautoescape %}
 {% endblock %}
 
templates/layerindex/recipes.html +1 -0
index 60a2667..4f073f2 100644
@@ -21,6 +21,7 @@
                             <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 'distro_search' url_branch %}">Distros</a></li>
+                            <li><a href="{% url 'class_search' url_branch %}">Classes</a></li>
 {% endautoescape %}
 {% endblock %}
 
Signature · 1 line
2.7.4