Commit 79cf47e8 authored by Dalahro's avatar Dalahro

Recherche inclus switchs et ports

parent 917e983f
......@@ -20,6 +20,8 @@ CHOICES3 = (
('2', 'Factures'),
('3', 'Bannissements'),
('4', 'Accès à titre gracieux'),
('6', 'Switchs'),
('5', 'Ports'),
)
......
......@@ -24,7 +24,15 @@
<h2>Résultats dans les banissements : </h2>
{% include "users/aff_bans.html" with ban_list=ban_list %}
{% endif %}
{% if not ban_list and not machine_list and not users_list and not facture_list and not white_list%}
{% if switch_list %}
<h2>Résultats dans les switchs : </h2>
{% include "topologie/aff_switch.html" with switch_list=switch_list %}
{% endif %}
{% if port_list %}
<h2>Résultats dans les ports : </h2>
{% include "topologie/aff_port.html" with port_list=port_list %}
{% endif %}
{% if not ban_list and not machine_list and not users_list and not facture_list and not white_list and not port_list and not switch_list%}
<h3>Aucun résultat</h3>
{% endif %}
<br />
......
......@@ -9,6 +9,7 @@ from django.template import Context, RequestContext, loader
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 cotisations.models import Facture
from search.models import SearchForm, SearchFormPlus
from users.views import has_access
......@@ -24,7 +25,7 @@ def search_result(search, type):
date_fin = None
states=[]
co=[]
aff=['0','1','2','3','4']
aff=[]
if(type):
aff = search.cleaned_data['affichage']
co = search.cleaned_data['connexion']
......@@ -33,7 +34,7 @@ def search_result(search, type):
date_fin = search.cleaned_data['date_fin']
date_query = Q()
if aff==[]:
aff = ['0','1','2','3','4']
aff = ['0','1','2','3','4','5','6']
if date_deb != None:
date_query = date_query & Q(date__gte=date_deb)
if date_fin != None:
......@@ -48,6 +49,8 @@ def search_result(search, type):
factures = None
bans = None
whitelists = None
switchlist = None
portlist = None
connexion = []
for i in aff:
......@@ -71,7 +74,11 @@ def search_result(search, type):
bans = Ban.objects.filter(query)
if i == '4':
whitelists = Whitelist.objects.filter(query)
return {'users_list': connexion, 'machine_list' : machines, 'facture_list' : factures, 'ban_list' : bans, 'white_list': whitelists}
if i == '5':
portlist = Port.objects.filter(details__icontains = search)
if i == '6':
switchlist = Switch.objects.filter(details__icontains = search)
return {'users_list': connexion, 'machine_list' : machines, 'facture_list' : factures, 'ban_list' : bans, 'white_list': whitelists, 'port_list':portlist, 'switch_list':switchlist}
def search(request):
if request.method == 'POST':
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment