Factor out stats updating

This commit is contained in:
Michal Čihař 2012-02-29 09:56:39 +01:00
parent 0ab1aabd03
commit 87d198909d

View File

@ -226,13 +226,18 @@ class Translation(models.Model):
Unit.objects.filter(translation = self, id__in = oldunits).delete()
# Update revision and stats
self.update_stats(False)
self.revision = blob.hexsha
self.save()
def update_stats(self, dosave = True):
total = self.unit_set.count()
fuzzy = self.unit_set.filter(fuzzy = True).count()
translated = self.unit_set.filter(translated = True).count()
self.fuzzy = round(fuzzy * 100.0 / total, 1)
self.translated = round(translated * 100.0 / total, 1)
self.revision = blob.hexsha
self.save()
if dosave:
self.save()
def git_commit(self, author):
'''