forked from DGNum/gestioCOF
Merge branch 'hotfix/autocomplete_no_value'
This commit is contained in:
commit
e4d51de569
2 changed files with 20 additions and 8 deletions
|
@ -14,6 +14,10 @@ from gestioncof.decorators import buro_required
|
||||||
|
|
||||||
class Clipper(object):
|
class Clipper(object):
|
||||||
def __init__(self, clipper, fullname):
|
def __init__(self, clipper, fullname):
|
||||||
|
if fullname is None:
|
||||||
|
fullname = ""
|
||||||
|
assert isinstance(clipper, str)
|
||||||
|
assert isinstance(fullname, str)
|
||||||
self.clipper = clipper
|
self.clipper = clipper
|
||||||
self.fullname = fullname
|
self.fullname = fullname
|
||||||
|
|
||||||
|
@ -62,17 +66,19 @@ def autocomplete(request):
|
||||||
))
|
))
|
||||||
if ldap_query != "(&)":
|
if ldap_query != "(&)":
|
||||||
# If none of the bits were legal, we do not perform the query
|
# If none of the bits were legal, we do not perform the query
|
||||||
|
entries = None
|
||||||
with Connection(settings.LDAP_SERVER_URL) as conn:
|
with Connection(settings.LDAP_SERVER_URL) as conn:
|
||||||
conn.search(
|
conn.search(
|
||||||
'dc=spi,dc=ens,dc=fr', ldap_query,
|
'dc=spi,dc=ens,dc=fr', ldap_query,
|
||||||
attributes=['uid', 'cn']
|
attributes=['uid', 'cn']
|
||||||
)
|
)
|
||||||
queries['clippers'] = conn.entries
|
entries = conn.entries
|
||||||
# Clearing redundancies
|
# Clearing redundancies
|
||||||
queries['clippers'] = [
|
queries['clippers'] = [
|
||||||
Clipper(clipper.uid, clipper.cn)
|
Clipper(entry.uid.value, entry.cn.value)
|
||||||
for clipper in queries['clippers']
|
for entry in entries
|
||||||
if str(clipper.uid) not in usernames
|
if entry.uid.value
|
||||||
|
and entry.uid.value not in usernames
|
||||||
]
|
]
|
||||||
|
|
||||||
# Resulting data
|
# Resulting data
|
||||||
|
|
|
@ -13,6 +13,10 @@ from kfet.models import Account
|
||||||
|
|
||||||
class Clipper(object):
|
class Clipper(object):
|
||||||
def __init__(self, clipper, fullname):
|
def __init__(self, clipper, fullname):
|
||||||
|
if fullname is None:
|
||||||
|
fullname = ""
|
||||||
|
assert isinstance(clipper, str)
|
||||||
|
assert isinstance(fullname, str)
|
||||||
self.clipper = clipper
|
self.clipper = clipper
|
||||||
self.fullname = fullname
|
self.fullname = fullname
|
||||||
|
|
||||||
|
@ -80,17 +84,19 @@ def account_create(request):
|
||||||
))
|
))
|
||||||
if ldap_query != "(&)":
|
if ldap_query != "(&)":
|
||||||
# If none of the bits were legal, we do not perform the query
|
# If none of the bits were legal, we do not perform the query
|
||||||
|
entries = None
|
||||||
with Connection(settings.LDAP_SERVER_URL) as conn:
|
with Connection(settings.LDAP_SERVER_URL) as conn:
|
||||||
conn.search(
|
conn.search(
|
||||||
'dc=spi,dc=ens,dc=fr', ldap_query,
|
'dc=spi,dc=ens,dc=fr', ldap_query,
|
||||||
attributes=['uid', 'cn']
|
attributes=['uid', 'cn']
|
||||||
)
|
)
|
||||||
queries['clippers'] = conn.entries
|
entries = conn.entries
|
||||||
# Clearing redundancies
|
# Clearing redundancies
|
||||||
queries['clippers'] = [
|
queries['clippers'] = [
|
||||||
Clipper(clipper.uid, clipper.cn)
|
Clipper(entry.uid.value, entry.cn.value)
|
||||||
for clipper in queries['clippers']
|
for entry in entries
|
||||||
if str(clipper.uid) not in usernames
|
if entry.uid.value
|
||||||
|
and entry.uid.value not in usernames
|
||||||
]
|
]
|
||||||
|
|
||||||
# Resulting data
|
# Resulting data
|
||||||
|
|
Loading…
Reference in a new issue