From 87d198909d0bbeea717a124e5a08bac747a9badc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Wed, 29 Feb 2012 09:56:39 +0100 Subject: [PATCH] Factor out stats updating --- trans/models.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/trans/models.py b/trans/models.py index f50648f96..cd552a4d6 100644 --- a/trans/models.py +++ b/trans/models.py @@ -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): '''