forked from 0x2620/pandora
default operators, type fix
This commit is contained in:
parent
503d17522d
commit
6c2358ed09
2 changed files with 3 additions and 2 deletions
|
@ -13,7 +13,7 @@ import models
|
||||||
|
|
||||||
|
|
||||||
def keyType(key):
|
def keyType(key):
|
||||||
if key in ('released'):
|
if key in ('released', ):
|
||||||
return "date"
|
return "date"
|
||||||
if key in ('year', 'cast.length'):
|
if key in ('year', 'cast.length'):
|
||||||
return "int"
|
return "int"
|
||||||
|
@ -66,8 +66,10 @@ class MovieManager(Manager):
|
||||||
conditions = []
|
conditions = []
|
||||||
for condition in data['query']['conditions']:
|
for condition in data['query']['conditions']:
|
||||||
k = condition.get('key', 'all')
|
k = condition.get('key', 'all')
|
||||||
|
if not k: k = 'all'
|
||||||
v = condition['value']
|
v = condition['value']
|
||||||
op = condition.get('operator', None)
|
op = condition.get('operator', None)
|
||||||
|
if not op: op = '~'
|
||||||
if op.startswith('!'):
|
if op.startswith('!'):
|
||||||
op = op[1:]
|
op = op[1:]
|
||||||
exclude = True
|
exclude = True
|
||||||
|
|
|
@ -95,7 +95,6 @@ def _parse_query(data, user):
|
||||||
for key in ('sort', 'keys', 'group', 'list', 'range', 'ids'):
|
for key in ('sort', 'keys', 'group', 'list', 'range', 'ids'):
|
||||||
if key in data:
|
if key in data:
|
||||||
query[key] = data[key]
|
query[key] = data[key]
|
||||||
print query
|
|
||||||
query['qs'] = models.Movie.objects.find(data, user)
|
query['qs'] = models.Movie.objects.find(data, user)
|
||||||
#group by only allows sorting by name or number of itmes
|
#group by only allows sorting by name or number of itmes
|
||||||
return query
|
return query
|
||||||
|
|
Loading…
Reference in a new issue