fix & queries with multiple item keys
This commit is contained in:
parent
683e4b2780
commit
9bab85e00a
1 changed files with 14 additions and 8 deletions
|
@ -229,17 +229,20 @@ def parseConditions(conditions, operator, user):
|
|||
if 'conditions' in condition:
|
||||
q = parseConditions(condition['conditions'],
|
||||
condition.get('operator', '&'), user)
|
||||
if q:
|
||||
if isinstance(q, list):
|
||||
conn += q
|
||||
elif q:
|
||||
conn.append(q)
|
||||
else:
|
||||
conn.append(parseCondition(condition, user))
|
||||
if conn:
|
||||
if operator == '|':
|
||||
q = conn[0]
|
||||
for c in conn[1:]:
|
||||
if operator == '|':
|
||||
q = q | c
|
||||
q = [q]
|
||||
else:
|
||||
q = q & c
|
||||
q = conn
|
||||
return q
|
||||
return Q()
|
||||
|
||||
|
@ -269,7 +272,8 @@ class ItemManager(Manager):
|
|||
conditions = parseConditions(data['query']['conditions'],
|
||||
data['query'].get('operator', '&'),
|
||||
user)
|
||||
qs = qs.filter(conditions)
|
||||
for c in conditions:
|
||||
qs = qs.filter(c)
|
||||
else:
|
||||
qs = qs.filter(id__in=lqs[0].items.all())
|
||||
return qs
|
||||
|
@ -302,7 +306,9 @@ class ItemManager(Manager):
|
|||
conditions = parseConditions(data.get('query', {}).get('conditions', []),
|
||||
data.get('query', {}).get('operator', '&'),
|
||||
user)
|
||||
qs = qs.filter(conditions)
|
||||
for c in conditions:
|
||||
qs = qs.filter(c)
|
||||
|
||||
#FIXME: can this be avoided? needed for grid/accessed/foo
|
||||
qs = qs.distinct()
|
||||
|
||||
|
|
Loading…
Reference in a new issue