From 581eeb1a0d89d0c7e678ac2726b33bccfa7f60af Mon Sep 17 00:00:00 2001 From: Dalahro Date: Thu, 24 Nov 2016 18:12:11 +0100 Subject: [PATCH] =?UTF-8?q?Fix=20bug=20recherche,=20divers=20am=C3=A9liora?= =?UTF-8?q?tions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- search/views.py | 8 +++++--- users/templates/users/aff_users.html | 4 ++-- users/views.py | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/search/views.py b/search/views.py index a4ed65d7..adbe4b65 100644 --- a/search/views.py +++ b/search/views.py @@ -47,15 +47,17 @@ def search_result(search, type, request): connexion = [] - recherche = {'users_list': None, 'machines_list' : None, 'facture_list' : None, 'ban_list' : None, 'white_list': None, 'port_list': None, 'switch_list': None} + recherche = {'users_list': None, 'machines_list' : [], '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)) & query1) + recherche['users_list'] = User.objects.filter((Q(room__name__icontains = search) | Q(pseudo__icontains = search) | Q(name__icontains = search) | Q(surname__icontains = search)) & query1).order_by('state', 'surname') if i == '1': - recherche['machines_list'] = Machine.objects.filter(query | Q(interface__dns__icontains = search) | Q(interface__mac_address__icontains = search)) + data = Interface.objects.filter(Q(machine__user__pseudo__icontains = search) | Q(machine__user__name__icontains = search) | Q(machine__user__surname__icontains = search) | Q(dns__icontains = search) | Q(mac_address__icontains = search) | Q(ipv4__ipv4__icontains = search)) + for d in data: + recherche['machines_list'].append(d.machine) if i == '2': recherche['facture_list'] = Facture.objects.filter(query & date_query) if i == '3': diff --git a/users/templates/users/aff_users.html b/users/templates/users/aff_users.html index 2830b1d1..3246a1aa 100644 --- a/users/templates/users/aff_users.html +++ b/users/templates/users/aff_users.html @@ -8,7 +8,7 @@ Prénom Nom Pseudo - Uid + Chambre Fin de cotisation le Connexion Profil @@ -19,7 +19,7 @@ {{ user.name }} {{ user.surname }} {{ user.pseudo }} - {{ user.uid_number }} + {{ user.room }} {% if user.is_adherent %}{{ user.end_adhesion }}{% else %}Non adhérent{% endif %} {% if user.has_access == True %} Active diff --git a/users/views.py b/users/views.py index 89a69385..fe52ec20 100644 --- a/users/views.py +++ b/users/views.py @@ -426,7 +426,7 @@ def del_listright(request): @permission_required('cableur') def index(request): """ Affiche l'ensemble des users, need droit cableur """ - users_list = User.objects.order_by('pk') + users_list = User.objects.order_by('state', 'name') paginator = Paginator(users_list, PAGINATION_NUMBER) page = request.GET.get('page') try: