Fixing global search
This commit is contained in:
parent
c162494cdc
commit
8283cfc44d
|
@ -86,18 +86,17 @@ def search(request):
|
||||||
|
|
||||||
if pattern:
|
if pattern:
|
||||||
jumper_list = Jumper.objects.filter(
|
jumper_list = Jumper.objects.filter(
|
||||||
Q(last_name__icontains=pattern)
|
Q(last_name__icontains=pattern) | Q(first_name__icontains=pattern)
|
||||||
| Q(first_name__icontains=pattern)
|
|
||||||
)
|
)
|
||||||
skill_list = Skill.objects.filter(
|
skill_list = Skill.objects.filter(
|
||||||
Q(longLabel__icontains=pattern) | Q(shortLabel__icontains=pattern)
|
Q(long_label__icontains=pattern) | Q(short_label__icontains=pattern)
|
||||||
)
|
)
|
||||||
|
|
||||||
context = {
|
context = {
|
||||||
'gymnast_list': jumper_list,
|
'jumper_list': jumper_list,
|
||||||
'skill_list': skill_list,
|
'skill_list': skill_list,
|
||||||
}
|
}
|
||||||
else:
|
else:
|
||||||
context = {}
|
context = {}
|
||||||
|
|
||||||
return render(request, "results.html", context)
|
return render(request, "search/results.html", context)
|
||||||
|
|
|
@ -73,7 +73,7 @@ class Skill(models.Model):
|
||||||
level = models.PositiveSmallIntegerField(default=0)
|
level = models.PositiveSmallIntegerField(default=0)
|
||||||
rank = models.PositiveSmallIntegerField(default=0)
|
rank = models.PositiveSmallIntegerField(default=0)
|
||||||
numeric_notation = models.CharField(max_length=25)
|
numeric_notation = models.CharField(max_length=25)
|
||||||
ancestor = models.ManyToManyField("self", null=True, blank=True)
|
ancestor = models.ManyToManyField("self")
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "%s (%s) - %s" % (
|
return "%s (%s) - %s" % (
|
||||||
|
|
|
@ -101,21 +101,12 @@
|
||||||
</button>
|
</button>
|
||||||
<div class="collapse navbar-collapse" id="navigation">
|
<div class="collapse navbar-collapse" id="navigation">
|
||||||
<ul class="navbar-nav ml-auto">
|
<ul class="navbar-nav ml-auto">
|
||||||
<!-- <li class="search-bar input-group">
|
<li class="search-bar input-group">
|
||||||
<button class="btn btn-link" id="search-button" data-toggle="modal" data-target="#searchModal">
|
<button class="btn btn-link" id="search-button" data-toggle="modal" data-target="#searchModal">
|
||||||
<i class="tim-icons icon-zoom-split"></i>
|
<i class="tim-icons icon-zoom-split"></i>
|
||||||
<span class="d-lg-none d-md-block">Search</span>
|
<span class="d-lg-none d-md-block">Search</span>
|
||||||
</button>
|
</button>
|
||||||
</li>
|
</li>
|
||||||
<li class="dropdown nav-item">
|
|
||||||
<a href="javascript:void(0)" class="dropdown-toggle nav-link" data-toggle="dropdown">
|
|
||||||
<i class="tim-icons icon-sound-wave"></i>
|
|
||||||
<p class="d-lg-none">Flash access</p>
|
|
||||||
</a>
|
|
||||||
<ul class="dropdown-menu dropdown-menu-right dropdown-navbar">
|
|
||||||
|
|
||||||
</ul>
|
|
||||||
</li> -->
|
|
||||||
<li class="dropdown nav-item">
|
<li class="dropdown nav-item">
|
||||||
<a href="#" class="dropdown-toggle nav-link" data-toggle="dropdown">
|
<a href="#" class="dropdown-toggle nav-link" data-toggle="dropdown">
|
||||||
<div class="photo">
|
<div class="photo">
|
||||||
|
|
|
@ -0,0 +1,83 @@
|
||||||
|
{% extends "base.html" %}
|
||||||
|
|
||||||
|
<!-- {% block page_title %}.: Search results :.{% endblock %} -->
|
||||||
|
|
||||||
|
{% block title %}Search results{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<div class="card mb-0">
|
||||||
|
{% if jumper_list or skill_list %}
|
||||||
|
{% if jumper_list %}
|
||||||
|
<div class="card-header">
|
||||||
|
<h4 class="card-title"> Jumper's results</h4>
|
||||||
|
</div>
|
||||||
|
<div class="card-body">
|
||||||
|
<div class="table-responsive">
|
||||||
|
<table class="table" data-sort="table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th></th>
|
||||||
|
<th>Lastname</th>
|
||||||
|
<th>Firsname</th>
|
||||||
|
<th>Age</th>
|
||||||
|
<th>Gender</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{% for jumper in jumper_list %}
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
</td>
|
||||||
|
<td><a href="{% url 'jumper_details' jumper.id %}">{{ jumper.last_name }}</a></td>
|
||||||
|
<td><a href="{% url 'jumper_details' jumper.id %}">{{ jumper.first_name }}</a></td>
|
||||||
|
<td>{{ jumper.age }}</td>
|
||||||
|
<td>{{ jumper.get_gender_display }}</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if skill_list %}
|
||||||
|
<div class="card-header">
|
||||||
|
<h4 class="card-title"> Skill's results</h4>
|
||||||
|
</div>
|
||||||
|
<div class="card-body">
|
||||||
|
<div class="table-responsive">
|
||||||
|
<table class="table" data-sort="table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th class="text-left">Label</th>
|
||||||
|
<th class="text-center">Notation</th>
|
||||||
|
<th class="header text-center">Diff.</th>
|
||||||
|
<th class="header text-center">Level</th>
|
||||||
|
<th class="header text-center">Rank</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{% for skill in skill_list %}
|
||||||
|
<tr>
|
||||||
|
<td class="text-left"> <a href="{% url 'skill_details' skill.id %}">{{ skill.short_label }}</a></td>
|
||||||
|
<td class="text-center">{{ skill.numeric_notation }}</td>
|
||||||
|
<td class="text-center">{{ skill.difficulty }}</td>
|
||||||
|
<td class="text-center">{{ skill.level }}</td>
|
||||||
|
<td class="text-center">{{ skill.rank }}</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% else %}
|
||||||
|
<div class="card-header">
|
||||||
|
<h4 class="card-title"> Search results</h4>
|
||||||
|
</div>
|
||||||
|
<div class="card-body">
|
||||||
|
<p>There are no items corresponding to your criterias</p>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% endblock %}
|
Loading…
Reference in New Issue