From 8dca4cb67652b36f06ac4a4015932fb00a89b6f5 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Tue, 25 Oct 2011 17:04:55 +0200 Subject: [PATCH 1/2] more find keys --- pandora/item/models.py | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/pandora/item/models.py b/pandora/item/models.py index 5de4b8aa..ef22e747 100644 --- a/pandora/item/models.py +++ b/pandora/item/models.py @@ -511,22 +511,23 @@ class Item(models.Model): ItemFind.objects.filter(item=self, key=key).delete() for key in settings.CONFIG['itemKeys']: - if key.get('find'): - i = key['id'] - if i == 'title': - save(i, u'\n'.join([self.get('title', 'Untitled'), - self.get('originalTitle', '')])) - elif i == 'filename': - save(i, - '\n'.join([f.path for f in self.files.all()])) - elif key['type'] == 'layer': - qs = Annotation.objects.filter(layer__name=i, item=self).order_by('start') - save(i, '\n'.join([l.value for l in qs])) - elif i != '*' and i not in self.facet_keys: - value = self.get(i) - if isinstance(value, list): - value = u'\n'.join(value) - save(i, value) + i = key['id'] + if i == 'title': + save(i, u'\n'.join([self.get('title', 'Untitled'), + self.get('originalTitle', '')])) + elif i == 'rightslevel': + save(i, self.level) + elif i == 'filename': + save(i, + '\n'.join([f.path for f in self.files.all()])) + elif key['type'] == 'layer': + qs = Annotation.objects.filter(layer__name=i, item=self).order_by('start') + save(i, '\n'.join([l.value for l in qs])) + elif i != '*' and i not in self.facet_keys: + value = self.get(i) + if isinstance(value, list): + value = u'\n'.join(value) + save(i, value) for key in self.facet_keys: if key == 'character': From 21cb2e351987de2afd908f6562dcf08c1b0781cf Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Tue, 25 Oct 2011 18:22:10 +0200 Subject: [PATCH 2/2] dont call save twice creating an annotation --- pandora/annotation/models.py | 8 ++++++-- pandora/archive/models.py | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/pandora/annotation/models.py b/pandora/annotation/models.py index 0695f2aa..833dc44a 100644 --- a/pandora/annotation/models.py +++ b/pandora/annotation/models.py @@ -108,11 +108,13 @@ class Annotation(models.Model): def set_public_id(self): public_id = Annotation.objects.filter(item=self.item, id__lt=self.id).count() self.public_id = "%s/%s" % ( self.item.itemId, ox.to26(public_id)) + Annotation.objects.filter(id=self.id).update(public_id=public_id) def save(self, *args, **kwargs): if not self.id: - super(Annotation, self).save(*args, **kwargs) - self.set_public_id() + set_public_id = True + else: + set_public_id = False #no clip or update clip if not self.clip and not self.layer.private or \ @@ -121,6 +123,8 @@ class Annotation(models.Model): self.clip, created = Clip.get_or_create(self.item, self.start, self.end) super(Annotation, self).save(*args, **kwargs) + if set_public_id: + self.set_public_id() def json(self, layer=False, keys=None): j = { diff --git a/pandora/archive/models.py b/pandora/archive/models.py index a0d49766..8391f3a5 100644 --- a/pandora/archive/models.py +++ b/pandora/archive/models.py @@ -122,7 +122,7 @@ class File(models.Model): self.pixels = int(self.width * self.height * float(utils.parse_decimal(self.framerate)) * self.duration) else: - self.is_video = os.path.splitext(self.path)[-1] in ('.avi', '.mkv', '.dv', '.ogv', '.mpeg', '.mov', '.webm') + self.is_video = os.path.splitext(self.path)[-1] in ('.avi', '.mkv', '.dv', '.ogv', '.mpeg', '.mov', '.webm', '.mp4', '.mpg') self.is_audio = os.path.splitext(self.path)[-1] in ('.mp3', '.wav', '.ogg', '.flac', '.oga') self.is_subtitle = os.path.splitext(self.path)[-1] in ('.srt', )