forked from 0x2620/pandora
add duration and items(number of clips) as possible keys for getEdit
This commit is contained in:
parent
e7b86872a7
commit
f94f25d7c7
1 changed files with 10 additions and 0 deletions
|
@ -221,7 +221,9 @@ class Edit(models.Model):
|
||||||
'editable',
|
'editable',
|
||||||
'rightslevel',
|
'rightslevel',
|
||||||
'id',
|
'id',
|
||||||
|
'items',
|
||||||
'clips',
|
'clips',
|
||||||
|
'duration',
|
||||||
'name',
|
'name',
|
||||||
'posterFrames',
|
'posterFrames',
|
||||||
'status',
|
'status',
|
||||||
|
@ -237,8 +239,16 @@ class Edit(models.Model):
|
||||||
for key in keys:
|
for key in keys:
|
||||||
if key == 'id':
|
if key == 'id':
|
||||||
response[key] = self.get_id()
|
response[key] = self.get_id()
|
||||||
|
elif key == 'items':
|
||||||
|
response[key] = self.clips.all().count()
|
||||||
elif key == 'clips':
|
elif key == 'clips':
|
||||||
response[key] = [c.json(user) for c in self.clips.all().order_by('index')]
|
response[key] = [c.json(user) for c in self.clips.all().order_by('index')]
|
||||||
|
elif key == 'duration':
|
||||||
|
if 'clips' in response:
|
||||||
|
clips = response['clips']
|
||||||
|
else:
|
||||||
|
clips = [c.json(user) for c in self.clips.all().order_by('index')]
|
||||||
|
response[key] = sum([c['duration'] for c in clips])
|
||||||
elif key == 'editable':
|
elif key == 'editable':
|
||||||
response[key] = self.editable(user)
|
response[key] = self.editable(user)
|
||||||
elif key == 'user':
|
elif key == 'user':
|
||||||
|
|
Loading…
Reference in a new issue