Rename bits -> search_words in kfet.autocomplete
This is typo, this variable has not the same name in `gestioncof.autocomplete` and `kfet.autocomplete`
This commit is contained in:
parent
84a39b41f2
commit
e98a407982
1 changed files with 15 additions and 14 deletions
|
@ -1,6 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
import ldap3
|
||||
from ldap3 import Connection
|
||||
|
||||
from django.shortcuts import render
|
||||
from django.http import Http404
|
||||
|
@ -33,25 +33,25 @@ def account_create(request):
|
|||
search_words = q.split()
|
||||
|
||||
# Fetching data from User, CofProfile and Account tables
|
||||
queries['kfet'] = Account.objects
|
||||
queries['users_cof'] = User.objects.filter(profile__is_cof = True)
|
||||
queries['users_notcof'] = User.objects.filter(profile__is_cof = False)
|
||||
queries['kfet'] = Account.objects
|
||||
queries['users_cof'] = User.objects.filter(profile__is_cof=True)
|
||||
queries['users_notcof'] = User.objects.filter(profile__is_cof=False)
|
||||
|
||||
for word in search_words:
|
||||
queries['kfet'] = queries['kfet'].filter(
|
||||
Q(cofprofile__user__username__icontains = word)
|
||||
| Q(cofprofile__user__first_name__icontains = word)
|
||||
| Q(cofprofile__user__last_name__icontains = word)
|
||||
Q(cofprofile__user__username__icontains=word)
|
||||
| Q(cofprofile__user__first_name__icontains=word)
|
||||
| Q(cofprofile__user__last_name__icontains=word)
|
||||
)
|
||||
queries['users_cof'] = queries['users_cof'].filter(
|
||||
Q(username__icontains = word)
|
||||
| Q(first_name__icontains = word)
|
||||
| Q(last_name__icontains = word)
|
||||
Q(username__icontains=word)
|
||||
| Q(first_name__icontains=word)
|
||||
| Q(last_name__icontains=word)
|
||||
)
|
||||
queries['users_notcof'] = queries['users_notcof'].filter(
|
||||
Q(username__icontains = word)
|
||||
| Q(first_name__icontains = word)
|
||||
| Q(last_name__icontains = word)
|
||||
Q(username__icontains=word)
|
||||
| Q(first_name__icontains=word)
|
||||
| Q(last_name__icontains=word)
|
||||
)
|
||||
|
||||
# Clearing redundancies
|
||||
|
@ -76,7 +76,8 @@ def account_create(request):
|
|||
if hasattr(settings, 'LDAP_SERVER_URL'):
|
||||
# Fetching
|
||||
ldap_query = '(|{:s})'.format(''.join(
|
||||
['(cn=*{bit:s}*)(uid=*{bit:s}*)'.format(**{"bit": bit}) for bit in bits]
|
||||
['(cn=*{bit:s}*)(uid=*{bit:s}*)'.format(bit=word)
|
||||
for word in search_words]
|
||||
))
|
||||
with Connection(settings.LDAP_SERVER_URL) as conn:
|
||||
conn.search(
|
||||
|
|
Loading…
Reference in a new issue