From f94f25d7c75805ab4e292b50d4f90b3e10d05d8a Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Sat, 13 Jul 2013 11:15:46 +0000 Subject: [PATCH] add duration and items(number of clips) as possible keys for getEdit --- pandora/edit/models.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pandora/edit/models.py b/pandora/edit/models.py index bc8ed80f..cde58199 100644 --- a/pandora/edit/models.py +++ b/pandora/edit/models.py @@ -221,7 +221,9 @@ class Edit(models.Model): 'editable', 'rightslevel', 'id', + 'items', 'clips', + 'duration', 'name', 'posterFrames', 'status', @@ -237,8 +239,16 @@ class Edit(models.Model): for key in keys: if key == 'id': response[key] = self.get_id() + elif key == 'items': + response[key] = self.clips.all().count() elif key == 'clips': 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': response[key] = self.editable(user) elif key == 'user':