From 55cd3b3dbb9be8659662aef732f7d054155d55ef Mon Sep 17 00:00:00 2001 From: Dalahro Date: Wed, 2 Nov 2016 00:52:56 +0100 Subject: [PATCH] Normalement ca devrait remarcher ce que je voulais faire remarcher --- search/views.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/search/views.py b/search/views.py index 89b174a4..a4ed65d7 100644 --- a/search/views.py +++ b/search/views.py @@ -41,20 +41,19 @@ def search_result(search, type, request): if date_fin != None: date_query = date_query & Q(date__lte=date_fin) search = search.cleaned_data['search_field'] - query = Q() + query1 = Q() for s in states: - query = query | Q(state = s) - - - connexion = [] - + query1 = query1 | Q(state = s) + + connexion = [] + recherche = {'users_list': None, 'machines_list' : None, 'facture_list' : None, 'ban_list' : None, 'white_list': None, 'port_list': None, 'switch_list': None} query = Q(user__pseudo__icontains = search) | Q(user__name__icontains = search) | Q(user__surname__icontains = search) for i in aff: if i == '0': - recherche['users_list'] = User.objects.filter(Q(pseudo__icontains = search) | Q(name__icontains = search) | Q(surname__icontains = search)) + recherche['users_list'] = User.objects.filter((Q(pseudo__icontains = search) | Q(name__icontains = search) | Q(surname__icontains = search)) & query1) if i == '1': recherche['machines_list'] = Machine.objects.filter(query | Q(interface__dns__icontains = search) | Q(interface__mac_address__icontains = search)) if i == '2':