filter lists, alloed editList to write query
This commit is contained in:
parent
0cdafdef9b
commit
425679811b
2 changed files with 9 additions and 2 deletions
|
@ -186,7 +186,14 @@ class ItemManager(Manager):
|
|||
if only_public:
|
||||
lqs = lqs.filter(public=True)
|
||||
if lqs.count() == 1:
|
||||
qs = qs.filter(listitem__list__id=lqs[0].id)
|
||||
if lqs[0].query:
|
||||
data = lqs[0].query
|
||||
conditions = parseConditions(data['query']['conditions'],
|
||||
data['query'].get('operator', '&'))
|
||||
if conditions:
|
||||
qs = qs.filter(conditions)
|
||||
else:
|
||||
qs = qs.filter(id__in=lqs[0].items.all())
|
||||
return qs
|
||||
|
||||
def find(self, data, user):
|
||||
|
|
|
@ -102,7 +102,7 @@ def editList(request):
|
|||
list = get_object_or_404_json(models.List, pk=data['list'])
|
||||
if list.editable(request.user):
|
||||
for key in data:
|
||||
if key in ('name', 'public'):
|
||||
if key in ('name', 'public', 'query'):
|
||||
setattr(list, key, data['key'])
|
||||
else:
|
||||
response = json_response(status=403, text='not allowed')
|
||||
|
|
Loading…
Reference in a new issue