forked from 0x2620/pandora
fix, id startswith query
This commit is contained in:
parent
d11eacd8ba
commit
e7255e6af6
1 changed files with 11 additions and 8 deletions
|
@ -61,8 +61,11 @@ def parseCondition(condition, user):
|
||||||
key_type = 'list'
|
key_type = 'list'
|
||||||
|
|
||||||
if key_type == "string":
|
if key_type == "string":
|
||||||
in_find=True
|
in_find = not k.startswith('itemId')
|
||||||
value_key = 'find__value'
|
if in_find:
|
||||||
|
value_key = 'find__value'
|
||||||
|
else:
|
||||||
|
value_key = k
|
||||||
if k in models.Item.facet_keys + ['title']:
|
if k in models.Item.facet_keys + ['title']:
|
||||||
in_find = False
|
in_find = False
|
||||||
facet_value = 'facets__value%s' % {
|
facet_value = 'facets__value%s' % {
|
||||||
|
@ -77,7 +80,7 @@ def parseCondition(condition, user):
|
||||||
v = models.Item.objects.filter(**{'facets__key':k, facet_value:v})
|
v = models.Item.objects.filter(**{'facets__key':k, facet_value:v})
|
||||||
k = 'id__in'
|
k = 'id__in'
|
||||||
else:
|
else:
|
||||||
value_key = 'find__value%s' % {
|
value_key = '%s%s' % (value_key, {
|
||||||
'==': '__iexact',
|
'==': '__iexact',
|
||||||
'>': '__gt',
|
'>': '__gt',
|
||||||
'>=': '__gte',
|
'>=': '__gte',
|
||||||
|
@ -85,23 +88,23 @@ def parseCondition(condition, user):
|
||||||
'<=': '__lte',
|
'<=': '__lte',
|
||||||
'^': '__istartswith',
|
'^': '__istartswith',
|
||||||
'$': '__iendswith',
|
'$': '__iendswith',
|
||||||
}.get(op, '__icontains')
|
}.get(op, '__icontains'))
|
||||||
|
|
||||||
k = str(k)
|
k = str(k)
|
||||||
if exclude:
|
if exclude:
|
||||||
if k == '*':
|
if k == '*':
|
||||||
q = ~Q(**{value_key: v})
|
q = ~Q(**{value_key: v})
|
||||||
elif in_find and not k.startswith('itemId'):
|
elif in_find:
|
||||||
q = ~Q(**{'find__key': k, value_key: v})
|
q = ~Q(**{'find__key': k, value_key: v})
|
||||||
else:
|
else:
|
||||||
q = ~Q(**{k: v})
|
q = ~Q(**{value_key: v})
|
||||||
else:
|
else:
|
||||||
if k == '*':
|
if k == '*':
|
||||||
q = Q(**{value_key: v})
|
q = Q(**{value_key: v})
|
||||||
elif in_find and not k.startswith('itemId'):
|
elif in_find:
|
||||||
q = Q(**{'find__key': k, value_key: v})
|
q = Q(**{'find__key': k, value_key: v})
|
||||||
else:
|
else:
|
||||||
q = Q(**{k: v})
|
q = Q(**{value_key: v})
|
||||||
return q
|
return q
|
||||||
elif key_type == 'list':
|
elif key_type == 'list':
|
||||||
q = Q(itemId=False)
|
q = Q(itemId=False)
|
||||||
|
|
Loading…
Reference in a new issue