filter lists, alloed editList to write query
This commit is contained in:
parent
fa623dc0b0
commit
6eed38520d
2 changed files with 9 additions and 2 deletions
|
@ -186,7 +186,14 @@ class ItemManager(Manager):
|
||||||
if only_public:
|
if only_public:
|
||||||
lqs = lqs.filter(public=True)
|
lqs = lqs.filter(public=True)
|
||||||
if lqs.count() == 1:
|
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
|
return qs
|
||||||
|
|
||||||
def find(self, data, user):
|
def find(self, data, user):
|
||||||
|
|
|
@ -102,7 +102,7 @@ def editList(request):
|
||||||
list = get_object_or_404_json(models.List, pk=data['list'])
|
list = get_object_or_404_json(models.List, pk=data['list'])
|
||||||
if list.editable(request.user):
|
if list.editable(request.user):
|
||||||
for key in data:
|
for key in data:
|
||||||
if key in ('name', 'public'):
|
if key in ('name', 'public', 'query'):
|
||||||
setattr(list, key, data['key'])
|
setattr(list, key, data['key'])
|
||||||
else:
|
else:
|
||||||
response = json_response(status=403, text='not allowed')
|
response = json_response(status=403, text='not allowed')
|
||||||
|
|
Loading…
Reference in a new issue