mirror of
git://git.yoctoproject.org/layerindex-web.git
synced 2025-07-19 20:59:01 +02:00
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>
This commit is contained in:
parent
44386eea41
commit
ffaee423ee
|
@ -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
|
||||
|
|
|
@ -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$',
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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):
|
||||
|
|
75
templates/layerindex/classes.html
Normal file
75
templates/layerindex/classes.html
Normal file
|
@ -0,0 +1,75 @@
|
|||
{% extends "base_toplevel.html" %}
|
||||
{% load i18n %}
|
||||
|
||||
{% comment %}
|
||||
|
||||
layerindex-web - class index page template
|
||||
|
||||
Copyright (C) 2013 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 %}
|
|
@ -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 %}
|
||||
|
|
|
@ -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 %}
|
||||
|
|
|
@ -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 %}
|
||||
|
|
|
@ -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 %}
|
||||
|
|
Loading…
Reference in New Issue
Block a user