8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-11-22 03:13:12 +00:00

Ajoute la recherche dans les chambres

This commit is contained in:
Maël Kervella 2017-11-02 16:06:44 +00:00
parent 45b691fc7d
commit f55de14401
3 changed files with 23 additions and 6 deletions

View file

@ -37,8 +37,9 @@ CHOICES_AFF = (
('2', 'Factures'),
('3', 'Bannissements'),
('4', 'Accès à titre gracieux'),
('6', 'Switchs'),
('5', 'Ports'),
('5', 'Chambres'),
('6', 'Ports'),
('7', 'Switchs'),
)

View file

@ -48,6 +48,10 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<h2>Résultats dans les banissements : </h2>
{% include "users/aff_bans.html" with ban_list=bans_list %}
{% endif %}
{% if rooms_list %}
<h2>Résultats dans les chambres : </h2>
{% include "topologie/aff_chambres.html" with room_list=rooms_list %}
{% endif %}
{% if switch_ports_list %}
<h2>Résultats dans les ports : </h2>
{% include "topologie/aff_port.html" with port_list=switch_ports_list %}
@ -56,7 +60,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<h2>Résultats dans les switchs : </h2>
{% 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%}
{% if not users_list and not machines_list and not factures_list and not whitelists_list and not bans_list and not rooms_list and not switch_ports_list and not switches_list %}
<h3>Aucun résultat</h3>
{% else %}
<h6>(Seulement les {{ max_result }} premiers résultats sont affichés dans chaque catégorie)</h6>

View file

@ -35,7 +35,7 @@ from django.contrib.auth.decorators import login_required
from django.db.models import Q
from users.models import User, Ban, Whitelist
from machines.models import Machine, Interface
from topologie.models import Port, Switch
from topologie.models import Port, Switch, Room
from cotisations.models import Facture
from preferences.models import GeneralOption
from search.forms import (
@ -68,6 +68,7 @@ def get_results(query, request, filters={}):
'factures_list' : Facture.objects.none(),
'bans_list' : Ban.objects.none(),
'whitelists_list': Whitelist.objects.none(),
'rooms_list': Room.objects.none(),
'switch_ports_list': Port.objects.none(),
'switches_list': Switch.objects.none()
}
@ -201,8 +202,19 @@ def get_results(query, request, filters={}):
SortTable.USERS_INDEX_WHITE
)
# Switch ports
# Rooms
if '5' in aff and request.user.has_perms(('cableur',)):
filter_rooms_list = Q(details__icontains=query) | Q(name__icontains=query)
results['rooms_list'] = Room.objects.filter(filter_rooms_list)
results['rooms_list'] = SortTable.sort(
results['rooms_list'],
request.GET.get('col'),
request.GET.get('order'),
SortTable.TOPOLOGIE_INDEX_ROOM
)
# Switch ports
if '6' in aff and request.user.has_perms(('cableur',)):
results['switch_ports_list'] = Port.objects.filter(details__icontains=query)
results['switch_ports_list'] = SortTable.sort(
results['switch_ports_list'],
@ -212,7 +224,7 @@ def get_results(query, request, filters={}):
)
# Switches
if '6' in aff and request.user.has_perms(('cableur',)):
if '7' 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'],