forked from 0x2620/pandora
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']
|
||||
op = condition.get('operator')
|
||||
find_key = None
|
||||
if not op:
|
||||
op = '='
|
||||
|
||||
if op.startswith('!'):
|
||||
op = op[1:]
|
||||
exclude = True
|
||||
return ~buildCondition(k, op[1:], v)
|
||||
else:
|
||||
exclude = False
|
||||
return buildCondition(k, op, v)
|
||||
|
||||
|
||||
def buildCondition(k, op, v):
|
||||
find_key = None
|
||||
|
||||
if k == 'id':
|
||||
v = ox.fromAZ(v)
|
||||
return Q(**{k: v})
|
||||
|
@ -55,16 +59,10 @@ def parseCondition(condition, user, item=None):
|
|||
}.get(op, '__icontains'))
|
||||
key = str(key)
|
||||
if find_key:
|
||||
if exclude:
|
||||
q = Q(**{'find__key': find_key, key: v})
|
||||
else:
|
||||
q = Q(**{'find__key': find_key, key: v})
|
||||
return Q(**{'find__key': find_key, key: v})
|
||||
else:
|
||||
if exclude:
|
||||
q = ~Q(**{key: v})
|
||||
else:
|
||||
q = Q(**{key: v})
|
||||
return q
|
||||
return Q(**{key: v})
|
||||
|
||||
|
||||
def parseConditions(conditions, operator, user, item=None):
|
||||
'''
|
||||
|
|
Loading…
Reference in a new issue