move calculated values into function
This commit is contained in:
parent
9b4c87b867
commit
a33c7f6325
1 changed files with 10 additions and 7 deletions
|
@ -108,11 +108,7 @@ class Annotation(models.Model):
|
||||||
else:
|
else:
|
||||||
return self.value
|
return self.value
|
||||||
|
|
||||||
def save(self, *args, **kwargs):
|
def update_calculated_values(self):
|
||||||
if not self.id:
|
|
||||||
super(Annotation, self).save(*args, **kwargs)
|
|
||||||
self.public_id = '%s/%s' % (self.item.itemId, ox.to32(self.id))
|
|
||||||
if self.duration != self.end - self.start:
|
|
||||||
self.duration = self.end - self.start
|
self.duration = self.end - self.start
|
||||||
if self.duration > 0:
|
if self.duration > 0:
|
||||||
self.hue, self.saturation, self.lightness = extract.average_color(
|
self.hue, self.saturation, self.lightness = extract.average_color(
|
||||||
|
@ -120,6 +116,13 @@ class Annotation(models.Model):
|
||||||
else:
|
else:
|
||||||
self.hue = self.saturation = self.lightness = 0
|
self.hue = self.saturation = self.lightness = 0
|
||||||
#FIXME: set volume here
|
#FIXME: set volume here
|
||||||
|
|
||||||
|
def save(self, *args, **kwargs):
|
||||||
|
if not self.id:
|
||||||
|
super(Annotation, self).save(*args, **kwargs)
|
||||||
|
self.public_id = '%s/%s' % (self.item.itemId, ox.to32(self.id))
|
||||||
|
if self.duration != self.end - self.start:
|
||||||
|
self.update_calculated_values()
|
||||||
super(Annotation, self).save(*args, **kwargs)
|
super(Annotation, self).save(*args, **kwargs)
|
||||||
|
|
||||||
def json(self, layer=False, keys=None):
|
def json(self, layer=False, keys=None):
|
||||||
|
|
Loading…
Reference in a new issue