Commit b3eb204c authored by Michal Čihař's avatar Michal Čihař

Use fancy progressbars for languages (issue #196)

parent 9cb42cda
...@@ -398,6 +398,48 @@ class Language(models.Model): ...@@ -398,6 +398,48 @@ class Language(models.Model):
return 0 return 0
return round(translated * 100.0 / total, 1) return round(translated * 100.0 / total, 1)
def get_fuzzy_percent(self):
'''
Returns status of translations in this language.
'''
from trans.models import Translation
translations = Translation.objects.filter(
language=self
).aggregate(
Sum('fuzzy'),
Sum('total')
)
fuzzy = translations['fuzzy__sum']
total = translations['total__sum']
# Prevent division by zero on no translations
if total == 0:
return 0
return round(fuzzy * 100.0 / total, 1)
def get_failing_checks_percent(self):
'''
Returns status of translations in this language.
'''
from trans.models import Translation
translations = Translation.objects.filter(
language=self
).aggregate(
Sum('failing_checks'),
Sum('total')
)
failing_checks = translations['failing_checks__sum']
total = translations['total__sum']
# Prevent division by zero on no translations
if total == 0:
return 0
return round(failing_checks * 100.0 / total, 1)
def get_html(self): def get_html(self):
''' '''
Returns html attributes for markup in this language, includes Returns html attributes for markup in this language, includes
......
...@@ -16,10 +16,10 @@ ...@@ -16,10 +16,10 @@
</tr> </tr>
<tbody> <tbody>
{% for lang in languages %} {% for lang in languages %}
{% with lang.get_translated_percent as percent %} {% with lang.get_translated_percent as percent and lang.get_fuzzy_percent as fuzzy and lang.get_failing_checks_percent as check_percent %}
<tr> <tr>
<th><a href="{{ lang.get_absolute_url }}">{{ lang }}</a></th> <th><a href="{{ lang.get_absolute_url }}">{{ lang }}</a></th>
<td><div class="progress" data-value="{{ percent|floatformat:0 }}"></div></td> <td><div class="progress" data-value="{{ percent|floatformat:0 }}" data-fuzzy="{{ fuzzy|floatformat:0 }}" data-checks="{{ check_percent|floatformat:0 }}"></div></td>
<td class="percent">{{ percent }}%</td> <td class="percent">{{ percent }}%</td>
</tr> </tr>
{% endwith %} {% endwith %}
......
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