merge
This commit is contained in:
commit
219a5bbf32
21 changed files with 294 additions and 446 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]}
|
||||
|
|
|
|||
|
|
@ -96,9 +96,7 @@ def parseConditions(conditions, operator, user):
|
|||
conn.append(q)
|
||||
pass
|
||||
else:
|
||||
if condition.get('value', '') != '' or \
|
||||
condition.get('operator', '') == '=':
|
||||
conn.append(parseCondition(condition, user))
|
||||
conn.append(parseCondition(condition, user))
|
||||
if conn:
|
||||
q = conn[0]
|
||||
for c in conn[1:]:
|
||||
|
|
|
|||
|
|
@ -46,9 +46,7 @@ def parseConditions(conditions, operator, user):
|
|||
conn.append(q)
|
||||
pass
|
||||
else:
|
||||
if condition.get('value', '') != '' or \
|
||||
condition.get('operator', '') == '=':
|
||||
conn.append(parseCondition(condition, user))
|
||||
conn.append(parseCondition(condition, user))
|
||||
if conn:
|
||||
q = conn[0]
|
||||
for c in conn[1:]:
|
||||
|
|
|
|||
|
|
@ -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]
|
||||
|
|
@ -165,9 +166,7 @@ def parseConditions(conditions, operator):
|
|||
conn.append(q)
|
||||
pass
|
||||
else:
|
||||
if condition.get('value', '') != '' or \
|
||||
condition.get('operator', '') == '=':
|
||||
conn.append(parseCondition(condition))
|
||||
conn.append(parseCondition(condition))
|
||||
if conn:
|
||||
q = conn[0]
|
||||
for c in conn[1:]:
|
||||
|
|
|
|||
|
|
@ -9,16 +9,8 @@ import models
|
|||
|
||||
def parseCondition(condition, user):
|
||||
'''
|
||||
condition: {
|
||||
value: "war"
|
||||
}
|
||||
or
|
||||
condition: {
|
||||
key: "year",
|
||||
value: "1970-1980,
|
||||
operator: "!="
|
||||
}
|
||||
'''
|
||||
print condition, user
|
||||
k = condition.get('key', 'name')
|
||||
k = {
|
||||
'user': 'user__username',
|
||||
|
|
@ -29,15 +21,16 @@ def parseCondition(condition, user):
|
|||
v = condition['value']
|
||||
op = condition.get('operator')
|
||||
if not op:
|
||||
op = ''
|
||||
op = '='
|
||||
if op.startswith('!'):
|
||||
op = op[1:]
|
||||
exclude = True
|
||||
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=[])
|
||||
|
|
@ -53,7 +46,6 @@ def parseCondition(condition, user):
|
|||
'^': '__istartswith',
|
||||
'$': '__iendswith',
|
||||
}.get(op, '__icontains'))
|
||||
|
||||
key = str(key)
|
||||
if exclude:
|
||||
q = ~Q(**{key: v})
|
||||
|
|
@ -89,9 +81,7 @@ def parseConditions(conditions, operator, user):
|
|||
conn.append(q)
|
||||
pass
|
||||
else:
|
||||
if condition.get('value', '') != '' or \
|
||||
condition.get('operator', '') == '=':
|
||||
conn.append(parseCondition(condition, user))
|
||||
conn.append(parseCondition(condition, user))
|
||||
if conn:
|
||||
q = conn[0]
|
||||
for c in conn[1:]:
|
||||
|
|
@ -142,4 +132,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,6 @@ def findLists(request):
|
|||
else:
|
||||
qs = _order_query(query['qs'], query['sort'])
|
||||
|
||||
#range
|
||||
response = json_response()
|
||||
if 'keys' in data:
|
||||
qs = qs[query['range'][0]:query['range'][1]]
|
||||
|
|
|
|||
|
|
@ -92,9 +92,7 @@ def parseConditions(conditions, operator, user):
|
|||
conn.append(q)
|
||||
pass
|
||||
else:
|
||||
if condition.get('value', '') != '' or \
|
||||
condition.get('operator', '') == '=':
|
||||
conn.append(parseCondition(condition, user))
|
||||
conn.append(parseCondition(condition, user))
|
||||
if conn:
|
||||
q = conn[0]
|
||||
for c in conn[1:]:
|
||||
|
|
|
|||
|
|
@ -47,9 +47,7 @@ def parseConditions(conditions, operator, user):
|
|||
conn.append(q)
|
||||
pass
|
||||
else:
|
||||
if condition.get('value', '') != '' or \
|
||||
condition.get('operator', '') == '=':
|
||||
conn.append(parseCondition(condition, user))
|
||||
conn.append(parseCondition(condition, user))
|
||||
if conn:
|
||||
q = conn[0]
|
||||
for c in conn[1:]:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue