ldap_crans: kludge support pour >= et <=
This commit is contained in:
parent
4dd908e746
commit
5e5a819b47
1 changed files with 7 additions and 3 deletions
|
@ -804,7 +804,7 @@ class CransLdap:
|
||||||
result[i] = []
|
result[i] = []
|
||||||
|
|
||||||
# Fonction utile
|
# Fonction utile
|
||||||
def build_filtre(champ, expr, neg=False):
|
def build_filtre(champ, expr, neg=False, comp=''):
|
||||||
"""
|
"""
|
||||||
Retourne une chaine pour recherche dans la base LDAP
|
Retourne une chaine pour recherche dans la base LDAP
|
||||||
du style (champ=expr) en adaptant les valeurs de expr au champ.
|
du style (champ=expr) en adaptant les valeurs de expr au champ.
|
||||||
|
@ -848,7 +848,7 @@ class CransLdap:
|
||||||
el = '(blacklist=%s)' % expr
|
el = '(blacklist=%s)' % expr
|
||||||
else:
|
else:
|
||||||
# Cas général
|
# Cas général
|
||||||
el = '(%s=%s)' % (champ, expr)
|
el = '(%s%s=%s)' % (champ, comp, expr)
|
||||||
if neg: el = '(!%s)' % el
|
if neg: el = '(!%s)' % el
|
||||||
return el
|
return el
|
||||||
|
|
||||||
|
@ -871,12 +871,16 @@ class CransLdap:
|
||||||
# Test de l'expression de recherche et classement par filtres
|
# Test de l'expression de recherche et classement par filtres
|
||||||
for cond in conds:
|
for cond in conds:
|
||||||
neg = False
|
neg = False
|
||||||
|
comp = ''
|
||||||
try:
|
try:
|
||||||
champ, expr = cond.strip().split('=')
|
champ, expr = cond.strip().split('=')
|
||||||
if champ[-1] == '!':
|
if champ[-1] == '!':
|
||||||
# Négation pour ce champ
|
# Négation pour ce champ
|
||||||
champ = champ[:-1]
|
champ = champ[:-1]
|
||||||
neg = True
|
neg = True
|
||||||
|
if champ[-1] in ['>', '<']:
|
||||||
|
comp = champ[-1]
|
||||||
|
champ = champ[0:-1]
|
||||||
except:
|
except:
|
||||||
raise ValueError(u'Syntaxe de recherche invalide (%s)' % cond)
|
raise ValueError(u'Syntaxe de recherche invalide (%s)' % cond)
|
||||||
|
|
||||||
|
@ -896,7 +900,7 @@ class CransLdap:
|
||||||
# Construction du filtre
|
# Construction du filtre
|
||||||
for i in filtres:
|
for i in filtres:
|
||||||
if champ in self.search_champs[i]:
|
if champ in self.search_champs[i]:
|
||||||
filtre[i] += build_filtre(champ, expr, neg)
|
filtre[i] += build_filtre(champ, expr, neg, comp)
|
||||||
ok = True
|
ok = True
|
||||||
if champ not in self.auto_search_machines_champs \
|
if champ not in self.auto_search_machines_champs \
|
||||||
and champ not in self.non_auto_search_machines_champs:
|
and champ not in self.non_auto_search_machines_champs:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue