set words/clips only if id exists

This commit is contained in:
j 2013-05-12 14:20:55 +02:00
parent f0acbd2bef
commit dd49b61a59

View file

@ -811,8 +811,9 @@ class Item(models.Model):
s.rightslevel = self.level
s.aspectratio = self.get('aspectratio')
s.words = sum([len(a.value.split()) for a in self.annotations.exclude(value='')])
s.clips = self.clips.count()
if self.id:
s.words = sum([len(a.value.split()) for a in self.annotations.exclude(value='')])
s.clips = self.clips.count()
videos = self.files.filter(selected=True).filter(Q(is_video=True)|Q(is_audio=True))
if videos.count() > 0: