dont filter empty conditions
This commit is contained in:
parent
1d894fc934
commit
7982ba6b29
7 changed files with 8 additions and 21 deletions
|
@ -96,9 +96,7 @@ def parseConditions(conditions, operator, user):
|
||||||
conn.append(q)
|
conn.append(q)
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
if condition.get('value', '') != '' or \
|
conn.append(parseCondition(condition, user))
|
||||||
condition.get('operator', '') == '=':
|
|
||||||
conn.append(parseCondition(condition, user))
|
|
||||||
if conn:
|
if conn:
|
||||||
q = conn[0]
|
q = conn[0]
|
||||||
for c in conn[1:]:
|
for c in conn[1:]:
|
||||||
|
|
|
@ -46,9 +46,7 @@ def parseConditions(conditions, operator, user):
|
||||||
conn.append(q)
|
conn.append(q)
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
if condition.get('value', '') != '' or \
|
conn.append(parseCondition(condition, user))
|
||||||
condition.get('operator', '') == '=':
|
|
||||||
conn.append(parseCondition(condition, user))
|
|
||||||
if conn:
|
if conn:
|
||||||
q = conn[0]
|
q = conn[0]
|
||||||
for c in conn[1:]:
|
for c in conn[1:]:
|
||||||
|
|
|
@ -166,9 +166,7 @@ def parseConditions(conditions, operator):
|
||||||
conn.append(q)
|
conn.append(q)
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
if condition.get('value', '') != '' or \
|
conn.append(parseCondition(condition))
|
||||||
condition.get('operator', '') == '=':
|
|
||||||
conn.append(parseCondition(condition))
|
|
||||||
if conn:
|
if conn:
|
||||||
q = conn[0]
|
q = conn[0]
|
||||||
for c in conn[1:]:
|
for c in conn[1:]:
|
||||||
|
|
|
@ -10,6 +10,7 @@ import models
|
||||||
def parseCondition(condition, user):
|
def parseCondition(condition, user):
|
||||||
'''
|
'''
|
||||||
'''
|
'''
|
||||||
|
print condition, user
|
||||||
k = condition.get('key', 'name')
|
k = condition.get('key', 'name')
|
||||||
k = {
|
k = {
|
||||||
'user': 'user__username',
|
'user': 'user__username',
|
||||||
|
@ -20,7 +21,7 @@ def parseCondition(condition, user):
|
||||||
v = condition['value']
|
v = condition['value']
|
||||||
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:]
|
op = op[1:]
|
||||||
exclude = True
|
exclude = True
|
||||||
|
@ -45,7 +46,6 @@ def parseCondition(condition, user):
|
||||||
'^': '__istartswith',
|
'^': '__istartswith',
|
||||||
'$': '__iendswith',
|
'$': '__iendswith',
|
||||||
}.get(op, '__icontains'))
|
}.get(op, '__icontains'))
|
||||||
|
|
||||||
key = str(key)
|
key = str(key)
|
||||||
if exclude:
|
if exclude:
|
||||||
q = ~Q(**{key: v})
|
q = ~Q(**{key: v})
|
||||||
|
@ -81,9 +81,7 @@ def parseConditions(conditions, operator, user):
|
||||||
conn.append(q)
|
conn.append(q)
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
if condition.get('value', '') != '' or \
|
conn.append(parseCondition(condition, user))
|
||||||
condition.get('operator', '') == '=':
|
|
||||||
conn.append(parseCondition(condition, user))
|
|
||||||
if conn:
|
if conn:
|
||||||
q = conn[0]
|
q = conn[0]
|
||||||
for c in conn[1:]:
|
for c in conn[1:]:
|
||||||
|
|
|
@ -96,7 +96,6 @@ def findLists(request):
|
||||||
else:
|
else:
|
||||||
qs = _order_query(query['qs'], query['sort'])
|
qs = _order_query(query['qs'], query['sort'])
|
||||||
|
|
||||||
qs = qs.distinct()
|
|
||||||
response = json_response()
|
response = json_response()
|
||||||
if 'keys' in data:
|
if 'keys' in data:
|
||||||
qs = qs[query['range'][0]:query['range'][1]]
|
qs = qs[query['range'][0]:query['range'][1]]
|
||||||
|
|
|
@ -92,9 +92,7 @@ def parseConditions(conditions, operator, user):
|
||||||
conn.append(q)
|
conn.append(q)
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
if condition.get('value', '') != '' or \
|
conn.append(parseCondition(condition, user))
|
||||||
condition.get('operator', '') == '=':
|
|
||||||
conn.append(parseCondition(condition, user))
|
|
||||||
if conn:
|
if conn:
|
||||||
q = conn[0]
|
q = conn[0]
|
||||||
for c in conn[1:]:
|
for c in conn[1:]:
|
||||||
|
|
|
@ -47,9 +47,7 @@ def parseConditions(conditions, operator, user):
|
||||||
conn.append(q)
|
conn.append(q)
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
if condition.get('value', '') != '' or \
|
conn.append(parseCondition(condition, user))
|
||||||
condition.get('operator', '') == '=':
|
|
||||||
conn.append(parseCondition(condition, user))
|
|
||||||
if conn:
|
if conn:
|
||||||
q = conn[0]
|
q = conn[0]
|
||||||
for c in conn[1:]:
|
for c in conn[1:]:
|
||||||
|
|
Loading…
Reference in a new issue