allow itemkeys to be requested in findClips
This commit is contained in:
parent
f23a480208
commit
be21595733
2 changed files with 12 additions and 10 deletions
|
@ -50,19 +50,18 @@ class Clip(models.Model):
|
||||||
|
|
||||||
def json(self, keys=None):
|
def json(self, keys=None):
|
||||||
j = {}
|
j = {}
|
||||||
for field in ('id', 'in', 'out', 'created', 'modified',
|
clip_keys = ('id', 'in', 'out', 'created', 'modified',
|
||||||
'hue', 'saturation', 'lightness', 'volume'):
|
'hue', 'saturation', 'lightness', 'volume')
|
||||||
j[field] = getattr(self, {
|
for key in clip_keys:
|
||||||
|
j[key] = getattr(self, {
|
||||||
'id': 'public_id',
|
'id': 'public_id',
|
||||||
'in': 'start',
|
'in': 'start',
|
||||||
'out': 'end',
|
'out': 'end',
|
||||||
}.get(field, field))
|
}.get(key, key))
|
||||||
if keys:
|
if keys:
|
||||||
_j = {}
|
for key in j.keys():
|
||||||
for key in keys:
|
if key not in keys:
|
||||||
if key in j:
|
del j[key]
|
||||||
_j[key] = j[key]
|
|
||||||
j = _j
|
|
||||||
if 'videoRatio' in keys:
|
if 'videoRatio' in keys:
|
||||||
streams = self.item.streams()
|
streams = self.item.streams()
|
||||||
if streams:
|
if streams:
|
||||||
|
@ -73,6 +72,9 @@ class Clip(models.Model):
|
||||||
for layer in filter(lambda l: l in keys, public_layers):
|
for layer in filter(lambda l: l in keys, public_layers):
|
||||||
j[layer] = [a.json(keys=['value'])['value']
|
j[layer] = [a.json(keys=['value'])['value']
|
||||||
for a in self.annotations.filter(layer__name=layer)]
|
for a in self.annotations.filter(layer__name=layer)]
|
||||||
|
for key in keys:
|
||||||
|
if key not in clip_keys and key not in j:
|
||||||
|
j[key] = self.item.get(key)
|
||||||
return j
|
return j
|
||||||
|
|
||||||
def __unicode__(self):
|
def __unicode__(self):
|
||||||
|
|
|
@ -71,7 +71,7 @@ def findClips(request):
|
||||||
query = parse_query(data, request.user)
|
query = parse_query(data, request.user)
|
||||||
qs = order_query(query['qs'], query['sort'])
|
qs = order_query(query['qs'], query['sort'])
|
||||||
if 'keys' in data:
|
if 'keys' in data:
|
||||||
qs = qs[query['range'][0]:query['range'][1]]
|
qs = qs.select_related()[query['range'][0]:query['range'][1]]
|
||||||
response['data']['items'] = [p.json(keys=data['keys']) for p in qs]
|
response['data']['items'] = [p.json(keys=data['keys']) for p in qs]
|
||||||
elif 'position' in query:
|
elif 'position' in query:
|
||||||
ids = [i.public_id for i in qs]
|
ids = [i.public_id for i in qs]
|
||||||
|
|
Loading…
Reference in a new issue