Document: fix negating id queries

This commit is contained in:
Will Thompson 2016-02-26 18:07:29 +00:00
parent 8c23bdff6d
commit 738a9282b4

View file

@ -24,11 +24,14 @@ def parseCondition(condition, user, item=None):
op = condition.get('operator') op = condition.get('operator')
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):
if k == 'id': if k == 'id':
v = ox.fromAZ(v) v = ox.fromAZ(v)
return Q(**{k: v}) return Q(**{k: v})
@ -41,11 +44,8 @@ def parseCondition(condition, user, item=None):
'$': '__iendswith', '$': '__iendswith',
}.get(op, '__icontains')) }.get(op, '__icontains'))
key = str(key) key = str(key)
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):
''' '''