findEntities: fix negated conditions, fixes #2876
This commit is contained in:
parent
cdaa50c4d3
commit
6008f3b44e
1 changed files with 11 additions and 13 deletions
|
@ -27,14 +27,18 @@ def parseCondition(condition, user, item=None):
|
||||||
|
|
||||||
v = condition['value']
|
v = condition['value']
|
||||||
op = condition.get('operator')
|
op = condition.get('operator')
|
||||||
find_key = None
|
|
||||||
if not op:
|
if not op:
|
||||||
op = '='
|
op = '='
|
||||||
|
|
||||||
if op.startswith('!'):
|
if op.startswith('!'):
|
||||||
op = op[1:]
|
return ~buildCondition(k, op[1:], v)
|
||||||
exclude = True
|
|
||||||
else:
|
else:
|
||||||
exclude = False
|
return buildCondition(k, op, v)
|
||||||
|
|
||||||
|
|
||||||
|
def buildCondition(k, op, v):
|
||||||
|
find_key = None
|
||||||
|
|
||||||
if k == 'id':
|
if k == 'id':
|
||||||
v = ox.fromAZ(v)
|
v = ox.fromAZ(v)
|
||||||
return Q(**{k: v})
|
return Q(**{k: v})
|
||||||
|
@ -55,16 +59,10 @@ def parseCondition(condition, user, item=None):
|
||||||
}.get(op, '__icontains'))
|
}.get(op, '__icontains'))
|
||||||
key = str(key)
|
key = str(key)
|
||||||
if find_key:
|
if find_key:
|
||||||
if exclude:
|
return Q(**{'find__key': find_key, key: v})
|
||||||
q = Q(**{'find__key': find_key, key: v})
|
|
||||||
else:
|
|
||||||
q = Q(**{'find__key': find_key, key: v})
|
|
||||||
else:
|
else:
|
||||||
if exclude:
|
return Q(**{key: v})
|
||||||
q = ~Q(**{key: v})
|
|
||||||
else:
|
|
||||||
q = Q(**{key: v})
|
|
||||||
return q
|
|
||||||
|
|
||||||
def parseConditions(conditions, operator, user, item=None):
|
def parseConditions(conditions, operator, user, item=None):
|
||||||
'''
|
'''
|
||||||
|
|
Loading…
Reference in a new issue