add duration and items(number of clips) as possible keys for getEdit

This commit is contained in:
j 2013-07-13 11:15:46 +00:00
parent e7b86872a7
commit f94f25d7c7

View file

@ -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':