Commit 89909dbe authored by Michal Čihař's avatar Michal Čihař

Count words when working with translation

parent 4af393a2
...@@ -593,6 +593,15 @@ class Translation(models.Model, URLMixin): ...@@ -593,6 +593,15 @@ class Translation(models.Model, URLMixin):
''' '''
Updates translation statistics. Updates translation statistics.
''' '''
self.total_words = self.unit_set.aggegate(
Sum('num_words')
)['num_words']
self.translated_words = self.unit_set.filter(
translated=True
).aggegate(
Sum('num_words')
)['num_words']
self.total = self.unit_set.count() self.total = self.unit_set.count()
self.fuzzy = self.unit_set.filter( self.fuzzy = self.unit_set.filter(
fuzzy=True fuzzy=True
...@@ -600,12 +609,14 @@ class Translation(models.Model, URLMixin): ...@@ -600,12 +609,14 @@ class Translation(models.Model, URLMixin):
self.translated = self.unit_set.filter( self.translated = self.unit_set.filter(
translated=True translated=True
).count() ).count()
self.failing_checks = self.unit_set.filter( self.failing_checks = self.unit_set.filter(
has_failing_check=True has_failing_check=True
).count() ).count()
self.have_suggestion = self.unit_set.filter( self.have_suggestion = self.unit_set.filter(
has_suggestion=True has_suggestion=True
).count() ).count()
self.save() self.save()
self.store_hash() self.store_hash()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment