mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-23 20:03:11 +00:00
Acl sur search
This commit is contained in:
parent
d2a32a50ce
commit
8af94c8536
1 changed files with 12 additions and 18 deletions
|
@ -21,7 +21,7 @@ def form(ctx, template, request):
|
||||||
c.update(csrf(request))
|
c.update(csrf(request))
|
||||||
return render_to_response(template, c, context_instance=RequestContext(request))
|
return render_to_response(template, c, context_instance=RequestContext(request))
|
||||||
|
|
||||||
def search_result(search, type):
|
def search_result(search, type, request):
|
||||||
date_deb = None
|
date_deb = None
|
||||||
date_fin = None
|
date_fin = None
|
||||||
states=[]
|
states=[]
|
||||||
|
@ -53,6 +53,8 @@ def search_result(search, type):
|
||||||
switchlist = None
|
switchlist = None
|
||||||
portlist = None
|
portlist = None
|
||||||
connexion = []
|
connexion = []
|
||||||
|
is_cableur = request.user.has_perms(('cableur',))
|
||||||
|
is_bofh = request.user.has_perms(('bofh',))
|
||||||
|
|
||||||
for i in aff:
|
for i in aff:
|
||||||
if i == '0':
|
if i == '0':
|
||||||
|
@ -79,26 +81,18 @@ def search_result(search, type):
|
||||||
portlist = Port.objects.filter(details__icontains = search)
|
portlist = Port.objects.filter(details__icontains = search)
|
||||||
if i == '6':
|
if i == '6':
|
||||||
switchlist = Switch.objects.filter(details__icontains = search)
|
switchlist = Switch.objects.filter(details__icontains = search)
|
||||||
return {'users_list': connexion, 'interfaces_list' : machines, 'facture_list' : factures, 'ban_list' : bans, 'white_list': whitelists, 'port_list':portlist, 'switch_list':switchlist}
|
return {'users_list': connexion, 'interfaces_list' : machines, 'facture_list' : factures, 'ban_list' : bans, 'white_list': whitelists, 'port_list':portlist, 'switch_list':switchlist, 'is_cableur':is_cableur, 'is_bofh':is_bofh}
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
def search(request):
|
def search(request):
|
||||||
if request.method == 'POST':
|
|
||||||
search = SearchForm(request.POST or None)
|
search = SearchForm(request.POST or None)
|
||||||
if search.is_valid():
|
if search.is_valid():
|
||||||
return form(search_result(search, False), 'search/index.html',request)
|
return form(search_result(search, False, request), 'search/index.html',request)
|
||||||
return form({'searchform' : search}, 'search/search.html', request)
|
return form({'searchform' : search}, 'search/search.html', request)
|
||||||
else:
|
|
||||||
search = SearchForm(request.POST or None)
|
|
||||||
return form({'searchform': search}, 'search/search.html',request)
|
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
def searchp(request):
|
def searchp(request):
|
||||||
if request.method == 'POST':
|
|
||||||
search = SearchFormPlus(request.POST or None)
|
search = SearchFormPlus(request.POST or None)
|
||||||
if search.is_valid():
|
if search.is_valid():
|
||||||
return form(search_result(search, True), 'search/index.html',request)
|
return form(search_result(search, True, request), 'search/index.html',request)
|
||||||
return form({'searchform' : search}, 'search/search.html', request)
|
return form({'searchform' : search}, 'search/search.html', request)
|
||||||
else:
|
|
||||||
search = SearchFormPlus(request.POST or None)
|
|
||||||
return form({'searchform': search}, 'search/search.html',request)
|
|
||||||
|
|
Loading…
Reference in a new issue