filter lists, alloed editList to write query

This commit is contained in:
j 2011-01-06 12:34:10 +05:30
parent fa623dc0b0
commit 6eed38520d
2 changed files with 9 additions and 2 deletions

View file

@ -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):

View file

@ -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')