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] = []
|
||||
|
||||
# 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
|
||||
du style (champ=expr) en adaptant les valeurs de expr au champ.
|
||||
|
@ -848,7 +848,7 @@ class CransLdap:
|
|||
el = '(blacklist=%s)' % expr
|
||||
else:
|
||||
# Cas général
|
||||
el = '(%s=%s)' % (champ, expr)
|
||||
el = '(%s%s=%s)' % (champ, comp, expr)
|
||||
if neg: el = '(!%s)' % el
|
||||
return el
|
||||
|
||||
|
@ -871,12 +871,16 @@ class CransLdap:
|
|||
# Test de l'expression de recherche et classement par filtres
|
||||
for cond in conds:
|
||||
neg = False
|
||||
comp = ''
|
||||
try:
|
||||
champ, expr = cond.strip().split('=')
|
||||
if champ[-1] == '!':
|
||||
# Négation pour ce champ
|
||||
champ = champ[:-1]
|
||||
neg = True
|
||||
if champ[-1] in ['>', '<']:
|
||||
comp = champ[-1]
|
||||
champ = champ[0:-1]
|
||||
except:
|
||||
raise ValueError(u'Syntaxe de recherche invalide (%s)' % cond)
|
||||
|
||||
|
@ -896,7 +900,7 @@ class CransLdap:
|
|||
# Construction du filtre
|
||||
for i in filtres:
|
||||
if champ in self.search_champs[i]:
|
||||
filtre[i] += build_filtre(champ, expr, neg)
|
||||
filtre[i] += build_filtre(champ, expr, neg, comp)
|
||||
ok = True
|
||||
if champ not in self.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