1
0
mirror of https://gitlab.com/animath/si/plateforme-corres2math.git synced 2024-12-05 02:06:52 +00:00

Regroup search results by model type

This commit is contained in:
Yohann D'ANELLO 2020-10-15 19:50:12 +02:00
parent f05d2cca0b
commit 7fb811b87f
2 changed files with 10 additions and 6 deletions

View File

@ -2,7 +2,7 @@
{{ object.user.last_name }}
{{ object.user.email }}
{{ object.type }}
{{ object.student_class }}
{{ object.get_student_class_display }}
{{ object.school }}
{{ object.team.name }}
{{ object.team.trigram }}

View File

@ -1,6 +1,6 @@
{% extends 'base.html' %}
{% load crispy_forms_filters i18n %}
{% load crispy_forms_filters highlight i18n %}
{% block content %}
<h2>{% trans "Search" %}</h2>
@ -16,10 +16,14 @@
<h3>{% trans "Results" %}</h3>
<div id="search-results">
{% for result in page.object_list %}
<p>
<a href="{{ result.object.get_absolute_url }}">{{ result.object }}</a>
</p>
{% regroup page.object_list by model_name as categories %}
{% for category in categories %}
<h4>{% trans category.grouper|capfirst %}</h4>
{% for result in category.list %}
<p>
<a href="{{ result.object.get_absolute_url }}">{{ result.object }}</a>
</p>
{% endfor %}
{% empty %}
<p>{% trans "No results found." %}</p>
{% endfor %}