url controller updates, refactoring
This commit is contained in:
parent
4a8954332a
commit
1d894fc934
18 changed files with 287 additions and 427 deletions
|
|
@ -3,7 +3,8 @@
|
|||
"canPlayClips": {"guest": 1, "member": 2, "staff": 3, "admin": 4},
|
||||
"canPlayVideo": {"guest": 0, "member": 1, "staff": 3, "admin": 4},
|
||||
"canSeeItem": {"guest": 2, "member": 2, "staff": 3, "admin": 4},
|
||||
"canSeeFiles": {"guest": -1, "member": -1, "staff": 3, "admin": 4}
|
||||
"canSeeFiles": {"guest": -1, "member": -1, "staff": 3, "admin": 4},
|
||||
"canSeeExtraItemViews": {"guest": false, "member": false, "staff": true, "admin": true}
|
||||
},
|
||||
"clipKeys": [
|
||||
{"id": "clip:text", "title": "Text", "type": "string"},
|
||||
|
|
@ -438,12 +439,12 @@
|
|||
},
|
||||
"itemViews": [
|
||||
{"id": "info", "title": "Info"},
|
||||
{"id": "statistics", "title": "Statistics"},
|
||||
{"id": "clips", "title": "Clips"},
|
||||
{"id": "video", "title": "Video"},
|
||||
{"id": "timeline", "title": "Timeline"},
|
||||
{"id": "map", "title": "Map"},
|
||||
{"id": "calendar", "title": "Calendar"},
|
||||
{"id": "data", "title": "Data"},
|
||||
{"id": "files", "title": "Files"}
|
||||
],
|
||||
"layers": [
|
||||
|
|
@ -527,9 +528,9 @@
|
|||
{"id": "favorites", "title": "Favorites", "public": true, "items": []},
|
||||
{"id": "most_popular", "title": "Most Popular", "query": {}},
|
||||
{"id": "recently_viewed", "title": "Recently Viewed", "query": {}},
|
||||
{"id": "1960s", "title": "1960s", "query": {"conditions": [{"key": "year", "value": "196", "operator": "^"}], "operator": ""}},
|
||||
{"id": "movies_with_full_video", "title": "Movies with Full Video", "query": {"conditions": [{"key": "canPlayVideo", "value": true, "operator": ""}], "operator": ""}},
|
||||
{"id": "movies_with_full_video", "title": "Movies with Clips", "query": {"conditions": [{"key": "canPlayClips", "value": true, "operator": ""}], "operator": ""}}
|
||||
{"id": "1960s", "title": "1960s", "query": {"conditions": [{"key": "year", "value": "196", "operator": "^"}], "operator": "&"}},
|
||||
{"id": "movies_with_full_video", "title": "Movies with Full Video", "query": {"conditions": [{"key": "canPlayVideo", "value": true, "operator": ""}], "operator": "&"}},
|
||||
{"id": "movies_with_full_video", "title": "Movies with Clips", "query": {"conditions": [{"key": "canPlayClips", "value": true, "operator": ""}], "operator": "&"}}
|
||||
],
|
||||
"favorite": [
|
||||
{"id": "rlx:watchme", "title": "rlx: watchme", "public": true, "items": [0, 1, 2, 3, 4]}
|
||||
|
|
|
|||
|
|
@ -98,7 +98,8 @@ def parseCondition(condition):
|
|||
elif key_type == 'list':
|
||||
q = Q(itemId=False)
|
||||
l = v.split(":")
|
||||
if len(l) == 2:
|
||||
if len(l) >= 2:
|
||||
l = (l[0], ":".join(l[1:]))
|
||||
lqs = list(List.objects.filter(name=l[1], user__username=l[0]))
|
||||
if len(lqs) == 1:
|
||||
l = lqs[0]
|
||||
|
|
|
|||
|
|
@ -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