From 9525d500cc3469cb599fd5d4f2118993307f677d Mon Sep 17 00:00:00 2001 From: Dalahro Date: Sat, 8 Oct 2016 00:38:02 +0200 Subject: [PATCH] =?UTF-8?q?Seulement=2015=20r=C3=A9sultats=20affich=C3=A9s?= =?UTF-8?q?=20dans=20la=20recherche?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- search/templates/search/index.html | 1 + search/views.py | 16 ++++++++-------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/search/templates/search/index.html b/search/templates/search/index.html index 9d60279d..0cdfe115 100644 --- a/search/templates/search/index.html +++ b/search/templates/search/index.html @@ -35,6 +35,7 @@ {% if not ban_list and not interfaces_list and not users_list and not facture_list and not white_list and not port_list and not switch_list%}

Aucun résultat

{% endif %} +
(Seulement les 15 premiers résultats sont affichés dans chaque catégorie)



diff --git a/search/views.py b/search/views.py index 22072e2e..4249f9b7 100644 --- a/search/views.py +++ b/search/views.py @@ -54,21 +54,21 @@ def search_result(search, type, request): for i in aff: if i == '0': - users = User.objects.filter((Q(pseudo__icontains = search) | Q(name__icontains = search) | Q(surname__icontains = search)) & query) + users = User.objects.filter((Q(pseudo__icontains = search) | Q(name__icontains = search) | Q(surname__icontains = search)) & query)[:15] query = Q(user__pseudo__icontains = search) | Q(user__name__icontains = search) | Q(user__surname__icontains = search) if i == '1': - machines = Interface.objects.filter(machine=Machine.objects.filter(query)) | Interface.objects.filter(Q(dns__icontains = search)) + machines = Machine.objects.filter(query)[:15] if i == '2': - factures = Facture.objects.filter(query & date_query) + factures = Facture.objects.filter(query & date_query)[:15] if i == '3': - bans = Ban.objects.filter(query) + bans = Ban.objects.filter(query)[:15] if i == '4': - whitelists = Whitelist.objects.filter(query) + whitelists = Whitelist.objects.filter(query)[:15] if i == '5': - portlist = Port.objects.filter(details__icontains = search) + portlist = Port.objects.filter(details__icontains = search)[:15] if i == '6': - switchlist = Switch.objects.filter(details__icontains = search) - return {'users_list': users, 'interfaces_list' : machines, 'facture_list' : factures, 'ban_list' : bans, 'white_list': whitelists, 'port_list':portlist, 'switch_list':switchlist} + switchlist = Switch.objects.filter(details__icontains = search)[:15] + return {'users_list': users, 'machines_list' : machines, 'facture_list' : factures, 'ban_list' : bans, 'white_list': whitelists, 'port_list':portlist, 'switch_list':switchlist} @login_required def search(request):