Update stats when storing units

This commit is contained in:
Michal Čihař 2012-02-28 10:17:57 +01:00
parent 5e1d2b39f7
commit f6bd455a2e

View File

@ -198,7 +198,12 @@ class Translation(models.Model):
# Delete not used units
Unit.objects.filter(translation = self, id__in = oldunits).delete()
# Update revision
# Update revision and stats
total = self.unit_set.count()
fuzzy = self.unit_set.filter(fuzzy = True).count()
translated = self.unit_set.filter(translated = True).count()
self.fuzzy = fuzzy * 1.0 / total
self.translated = translated * 1.0 / total
self.revision = blob.hexsha
self.save()