forked from 0x2620/pandora
url controller updates, refactoring
This commit is contained in:
parent
4a8954332a
commit
1d894fc934
18 changed files with 287 additions and 427 deletions
|
|
@ -9,15 +9,6 @@ import models
|
|||
|
||||
def parseCondition(condition, user):
|
||||
'''
|
||||
condition: {
|
||||
value: "war"
|
||||
}
|
||||
or
|
||||
condition: {
|
||||
key: "year",
|
||||
value: "1970-1980,
|
||||
operator: "!="
|
||||
}
|
||||
'''
|
||||
k = condition.get('key', 'name')
|
||||
k = {
|
||||
|
|
@ -36,8 +27,9 @@ def parseCondition(condition, user):
|
|||
else:
|
||||
exclude = False
|
||||
if k == 'id':
|
||||
v = v.split(':')
|
||||
if len(v) == 2:
|
||||
v = v.split(":")
|
||||
if len(v) >= 2:
|
||||
v = (v[0], ":".join(v[1:]))
|
||||
q = Q(user__username=v[0], name=v[1])
|
||||
else:
|
||||
q = Q(id__in=[])
|
||||
|
|
@ -142,4 +134,4 @@ class ListManager(Manager):
|
|||
qs = qs.filter(Q(status='public') | Q(status='featured'))
|
||||
else:
|
||||
qs = qs.filter(Q(status='public') | Q(status='featured') | Q(user=user))
|
||||
return qs
|
||||
return qs.distinct()
|
||||
|
|
|
|||
|
|
@ -13,7 +13,9 @@ from item import utils
|
|||
from item.models import Item
|
||||
|
||||
def get_list_or_404_json(id):
|
||||
username, listname = id.split(':')
|
||||
id = id.split(':')
|
||||
username = id[0]
|
||||
listname = ":".join(id[1:])
|
||||
return get_object_or_404_json(models.List, user__username=username, name=listname)
|
||||
|
||||
def _order_query(qs, sort):
|
||||
|
|
@ -94,7 +96,7 @@ def findLists(request):
|
|||
else:
|
||||
qs = _order_query(query['qs'], query['sort'])
|
||||
|
||||
#range
|
||||
qs = qs.distinct()
|
||||
response = json_response()
|
||||
if 'keys' in data:
|
||||
qs = qs[query['range'][0]:query['range'][1]]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue