From 45b691fc7dc7f64967cc7f8c5ea104424d70a84a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABl=20Kervella?= Date: Thu, 2 Nov 2017 15:09:24 +0000 Subject: [PATCH] =?UTF-8?q?Renommage=20des=20listes=20de=20r=C3=A9sultats?= =?UTF-8?q?=20+=20fix=20"Aucun=20r=C3=A9sultat"=20&=20droit=20cableur?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- search/templates/search/index.html | 29 +++++++++++---------- search/views.py | 42 +++++++++++++++--------------- 2 files changed, 36 insertions(+), 35 deletions(-) diff --git a/search/templates/search/index.html b/search/templates/search/index.html index 859193fb..c65807fb 100644 --- a/search/templates/search/index.html +++ b/search/templates/search/index.html @@ -36,30 +36,31 @@ with this program; if not, write to the Free Software Foundation, Inc.,

Résultats dans les machines :

{% include "machines/aff_machines.html" with machines_list=machines_list %} {% endif %} - {% if facture_list %} + {% if factures_list %}

Résultats dans les factures :

- {% include "cotisations/aff_cotisations.html" with facture_list=facture_list %} + {% include "cotisations/aff_cotisations.html" with facture_list=factures_list %} {% endif %} - {% if white_list %} + {% if whitelists_list %}

Résultats dans les accès à titre gracieux :

- {% include "users/aff_whitelists.html" with white_list=white_list %} + {% include "users/aff_whitelists.html" with white_list=whitelists_list %} {% endif %} - {% if ban_list %} + {% if bans_list %}

Résultats dans les banissements :

- {% include "users/aff_bans.html" with ban_list=ban_list %} + {% include "users/aff_bans.html" with ban_list=bans_list %} {% endif %} - {% if switch_list %} -

Résultats dans les switchs :

- {% include "topologie/aff_switch.html" with switch_list=switch_list %} - {% endif %} - {% if port_list %} + {% if switch_ports_list %}

Résultats dans les ports :

- {% include "topologie/aff_port.html" with port_list=port_list %} + {% include "topologie/aff_port.html" with port_list=switch_ports_list %} {% endif %} - {% 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%} + {% if switches_list %} +

Résultats dans les switchs :

+ {% include "topologie/aff_switch.html" with switch_list=switches_list %} + {% endif %} + {% if not users_list and not machines_list and not factures_list and not whitelists_list and not bans_list and not switch_ports_list and not switches_list%}

Aucun résultat

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



diff --git a/search/views.py b/search/views.py index 79c0c5c4..452030c2 100644 --- a/search/views.py +++ b/search/views.py @@ -65,11 +65,11 @@ def get_results(query, request, filters={}): results = { 'users_list': User.objects.none(), 'machines_list' : Machine.objects.none(), - 'facture_list' : Facture.objects.none(), - 'ban_list' : Ban.objects.none(), - 'white_list': Whitelist.objects.none(), - 'port_list': Port.objects.none(), - 'switch_list': Switch.objects.none() + 'factures_list' : Facture.objects.none(), + 'bans_list' : Ban.objects.none(), + 'whitelists_list': Whitelist.objects.none(), + 'switch_ports_list': Port.objects.none(), + 'switches_list': Switch.objects.none() } users_filter = Q( @@ -139,9 +139,9 @@ def get_results(query, request, filters={}): filter_facture_list &= Q(date__gte=start) if end != None: filter_facture_list &= Q(date__lte=end) - results['facture_list'] = Facture.objects.filter(filter_facture_list) - results['facture_list'] = SortTable.sort( - results['facture_list'], + results['factures_list'] = Facture.objects.filter(filter_facture_list) + results['factures_list'] = SortTable.sort( + results['factures_list'], request.GET.get('col'), request.GET.get('order'), SortTable.COTISATIONS_INDEX @@ -166,9 +166,9 @@ def get_results(query, request, filters={}): ) | ( Q(date_start__gte=end) & Q(date_end__lte=end) ) - results['ban_list'] = Ban.objects.filter(users_filter & date_filter) - results['ban_list'] = SortTable.sort( - results['ban_list'], + results['bans_list'] = Ban.objects.filter(users_filter & date_filter) + results['bans_list'] = SortTable.sort( + results['bans_list'], request.GET.get('col'), request.GET.get('order'), SortTable.USERS_INDEX_BAN @@ -193,9 +193,9 @@ def get_results(query, request, filters={}): ) | ( Q(date_start__gte=end) & Q(date_end__lte=end) ) - results['white_list'] = Whitelist.objects.filter(users_filter & date_filter) - results['white_list'] = SortTable.sort( - results['white_list'], + results['whitelists_list'] = Whitelist.objects.filter(users_filter & date_filter) + results['whitelists_list'] = SortTable.sort( + results['whitelists_list'], request.GET.get('col'), request.GET.get('order'), SortTable.USERS_INDEX_WHITE @@ -203,19 +203,19 @@ def get_results(query, request, filters={}): # Switch ports if '5' in aff and request.user.has_perms(('cableur',)): - results['port_list'] = Port.objects.filter(details__icontains=query) - results['port_list'] = SortTable.sort( - results['port_list'], + results['switch_ports_list'] = Port.objects.filter(details__icontains=query) + results['switch_ports_list'] = SortTable.sort( + results['switch_ports_list'], request.GET.get('col'), request.GET.get('order'), SortTable.TOPOLOGIE_INDEX_PORT ) # Switches - if '6' in aff and request.user.has_perms(('cableur')): - results['switch_list'] = Switch.objects.filter(details__icontains=query) - results['switch_list'] = SortTable.sort( - results['switch_list'], + if '6' in aff and request.user.has_perms(('cableur',)): + results['switches_list'] = Switch.objects.filter(details__icontains=query) + results['switches_list'] = SortTable.sort( + results['switches_list'], request.GET.get('col'), request.GET.get('order'), SortTable.TOPOLOGIE_INDEX