Allow 'query' to be omitted from find*() (fixes #2883)
I hit this in findDocuments() so thought I'd fix them all.
This commit is contained in:
parent
b121b58a86
commit
47d8d67c3d
7 changed files with 22 additions and 12 deletions
|
|
@ -116,8 +116,9 @@ class DocumentManager(Manager):
|
|||
|
||||
#join query with operator
|
||||
qs = self.get_query_set()
|
||||
conditions = parseConditions(data['query'].get('conditions', []),
|
||||
data['query'].get('operator', '&'),
|
||||
query = data.get('query', {})
|
||||
conditions = parseConditions(query.get('conditions', []),
|
||||
query.get('operator', '&'),
|
||||
user, item)
|
||||
if conditions:
|
||||
qs = qs.filter(conditions)
|
||||
|
|
|
|||
|
|
@ -148,7 +148,7 @@ def _order_query(qs, sort, item=None):
|
|||
return qs
|
||||
|
||||
def get_item(query):
|
||||
for c in query.get('conditions'):
|
||||
for c in query.get('conditions', []):
|
||||
if c.get('key') == 'item':
|
||||
return c.get('value')
|
||||
return None
|
||||
|
|
@ -161,7 +161,7 @@ def parse_query(data, user):
|
|||
if key in data:
|
||||
query[key] = data[key]
|
||||
query['qs'] = models.Document.objects.find(data, user).exclude(name='')
|
||||
query['item'] = get_item(data['query'])
|
||||
query['item'] = get_item(data.get('query', {}))
|
||||
return query
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue