From e482e0e7e12e7f2aa41e09ddccfbe2ec22df7de2 Mon Sep 17 00:00:00 2001 From: Dalahro <augustin.lemesle@supelec.fr> 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 @@ <th>Prénom</th> <th>Nom</th> <th>Pseudo</th> - <th>Uid</th> + <th>Chambre</th> <th>Fin de cotisation le</th> <th>Connexion</th> <th>Profil</th> @@ -19,7 +19,7 @@ <td>{{ user.name }}</td> <td>{{ user.surname }}</td> <td>{{ user.pseudo }}</td> - <td>{{ user.uid_number }}</td> + <td>{{ user.room }}</td> <td>{% if user.is_adherent %}{{ user.end_adhesion }}{% else %}Non adhérent{% endif %}</td> <td>{% if user.has_access == True %} <font color="green">Active</font> 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: