Store absolute numbers of messages rather than percent

This commit is contained in:
Michal Čihař 2012-03-01 14:22:52 +01:00
parent 8ec07f4f35
commit f7c156b3d9
3 changed files with 17 additions and 11 deletions

View File

@ -15,11 +15,11 @@
{% for trans in object.translation_set.all %}
<li><a href="{{ trans.get_absolute_url }}">{{ 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 %}

View File

@ -4,7 +4,7 @@
{% include "subproject_info.html" %}
{% endwith %}
<p>
{% 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 %}

View File

@ -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()