From f7c156b3d940b92d11967a063e00c1c92a7aad0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Thu, 1 Mar 2012 14:22:52 +0100 Subject: [PATCH] Store absolute numbers of messages rather than percent --- html/subproject.html | 4 ++-- html/translation_info.html | 2 +- trans/models.py | 22 ++++++++++++++-------- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/html/subproject.html b/html/subproject.html index 7d670fa9f..8eeac7cf5 100644 --- a/html/subproject.html +++ b/html/subproject.html @@ -15,11 +15,11 @@ {% for trans in object.translation_set.all %}
  • {{ trans.language.name }} {% if trans.fuzzy %} - {% blocktrans with trans.translated as translated and trans.fuzzy as fuzzy %} + {% blocktrans with trans.get_translated_percent as translated and trans.get_fuzzy_percent as fuzzy %} ({{ translated }}% translated, {{ fuzzy }}% fuzzy) {% endblocktrans %} {% else %} - {% blocktrans with trans.translated as translated %} + {% blocktrans with trans.get_translated_percent as translated %} ({{ translated }}% translated) {% endblocktrans %} {% endif %} diff --git a/html/translation_info.html b/html/translation_info.html index 3850cab88..94fc7f706 100644 --- a/html/translation_info.html +++ b/html/translation_info.html @@ -4,7 +4,7 @@ {% include "subproject_info.html" %} {% endwith %}

    -{% blocktrans with object.unit_set.all.count as count and object.translated as translated and object.fuzzy as fuzzy %} +{% blocktrans with object.unit_set.all.count as count and object.get_translated_percent as translated and object.get_fuzzy_percent as fuzzy %} There are {{ count }} strings, out of which {{ translated }}% is translated and {{ fuzzy }}% is fuzzy. {% endblocktrans %} diff --git a/trans/models.py b/trans/models.py index 7d25c3417..5dfbcf4f2 100644 --- a/trans/models.py +++ b/trans/models.py @@ -176,16 +176,24 @@ class SubProject(models.Model): class Translation(models.Model): subproject = models.ForeignKey(SubProject) language = models.ForeignKey(Language) - translated = models.FloatField(default = 0, db_index = True) - fuzzy = models.FloatField(default = 0, db_index = True) revision = models.CharField(max_length = 40, default = '', blank = True) - filename = models.CharField(max_length = 200) + filename = models.CharField(max_length = 200)\ + + translated = models.IntegerField(default = 0, db_index = True) + fuzzy = models.IntegerField(default = 0, db_index = True) + total = models.IntegerField(default = 0, db_index = True) objects = TranslationManager() class Meta: ordering = ['language__name'] + def get_fuzzy_percent(self): + return round(self.fuzzy * 100.0 / self.total, 1) + + def get_translated_percent(self): + return round(self.translated * 100.0 / self.total, 1) + @models.permalink def get_absolute_url(self): return ('trans.views.show_translation', (), { @@ -255,11 +263,9 @@ class Translation(models.Model): def update_stats(self, blob = None): if blob is None: blob = self.get_git_blob() - 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.total = self.unit_set.count() + self.fuzzy = self.unit_set.filter(fuzzy = True).count() + self.translated = self.unit_set.filter(translated = True).count() self.revision = blob.hexsha self.save()