From fd39f122ad6e59425a1be1e1cae12ec5fbac4fba Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Sat, 29 Oct 2011 16:12:28 +0200 Subject: [PATCH] annotation ids --- pandora/annotation/models.py | 9 +++++---- pandora/item/models.py | 2 ++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/pandora/annotation/models.py b/pandora/annotation/models.py index 74e76eff..bdca993d 100644 --- a/pandora/annotation/models.py +++ b/pandora/annotation/models.py @@ -109,12 +109,13 @@ class Annotation(models.Model): return self.value 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=self.public_id) + if self.id: + 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=self.public_id) def save(self, *args, **kwargs): - set_public_id = not self.id + set_public_id = not self.id or not self.public_id #no clip or update clip if not self.clip and not self.layer.private or \ diff --git a/pandora/item/models.py b/pandora/item/models.py index 57a16f34..d31c21e7 100644 --- a/pandora/item/models.py +++ b/pandora/item/models.py @@ -340,6 +340,8 @@ class Item(models.Model): #FIXME: should this really happen for annotations? for a in self.annotations.all(): a.item = other + a.public_id = None + a.save() if hasattr(self, 'files'): for f in self.files.all():