diff --git a/pandora/annotation/models.py b/pandora/annotation/models.py index d4a80946c..426294372 100644 --- a/pandora/annotation/models.py +++ b/pandora/annotation/models.py @@ -48,6 +48,12 @@ class Annotation(models.Model): def set_public_id(self): if self.id: public_id = Annotation.objects.filter(item=self.item, id__lt=self.id).count() + 1 + if public_id > 1: + previous = Annotation.objects.filter(item=self.item, + id__lt=self.id).order_by('-id')[0] + if not previous.public_id: + previous.set_public_id() + public_id = ox.fromAZ(previous.public_id.split('/')[-1]) + 1 self.public_id = "%s/%s" % (self.item.itemId, ox.toAZ(public_id)) Annotation.objects.filter(id=self.id).update(public_id=self.public_id)