From 484b33e39dbb30b60bf789ca1b49d26b41d21dfb Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Mon, 16 Feb 2015 16:10:45 +0000 Subject: [PATCH] add option to return item keys in findAnnotation --- pandora/annotation/models.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/pandora/annotation/models.py b/pandora/annotation/models.py index c6302405a..d34fb442c 100644 --- a/pandora/annotation/models.py +++ b/pandora/annotation/models.py @@ -215,6 +215,11 @@ class Annotation(models.Model): from entity.models import Entity return Entity.get(self.value) + annotation_keys = ( + 'id', 'in', 'out', 'value', 'created', 'modified', + 'duration', 'layer', 'item', 'videoRatio', 'languages', + 'entity', 'event', 'place' + ) def json(self, layer=False, keys=None, user=None): j = { 'user': self.user.username, @@ -269,6 +274,13 @@ class Annotation(models.Model): streams = self.item.streams() if streams: j['videoRatio'] = streams[0].aspect_ratio + for key in keys: + if key not in self.annotation_keys and key not in j: + value = self.item.get(key) or self.item.json.get(key) + if not value and hasattr(self.item.sort, key): + value = getattr(self.item.sort, key) + if value != None: + j[key] = value subtitles = get_by_key(settings.CONFIG['layers'], 'isSubtitles', True) if subtitles: if 'id' in j and self.layer == subtitles['id'] and not self.value: