From 738a9282b42cb3295b50b5061453ac172aa0be2c Mon Sep 17 00:00:00 2001 From: Will Thompson Date: Fri, 26 Feb 2016 18:07:29 +0000 Subject: [PATCH] Document: fix negating id queries --- pandora/document/managers.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/pandora/document/managers.py b/pandora/document/managers.py index 283a148a..0c50cbc7 100644 --- a/pandora/document/managers.py +++ b/pandora/document/managers.py @@ -24,11 +24,14 @@ def parseCondition(condition, user, item=None): op = condition.get('operator') 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): if k == 'id': v = ox.fromAZ(v) return Q(**{k: v}) @@ -41,11 +44,8 @@ def parseCondition(condition, user, item=None): '$': '__iendswith', }.get(op, '__icontains')) key = str(key) - if exclude: - q = ~Q(**{key: v}) - else: - q = Q(**{key: v}) - return q + return Q(**{key: v}) + def parseConditions(conditions, operator, user, item=None): '''