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

Summary stats on title page

parent e1571b96
...@@ -5,11 +5,24 @@ ...@@ -5,11 +5,24 @@
<h2>{% trans "Projects" %}</h2> <h2>{% trans "Projects" %}</h2>
<ul> <table>
<thead>
<tr>
<th>{% trans "Project" %}</th>
<th colspan="2">{% trans "Translated" %}</th>
</tr>
<tbody>
{% for prj in projects %} {% for prj in projects %}
<li><a href="{{ prj.get_absolute_url }}">{{ prj.name }}</a></li> {% with prj.get_translated_percent as percent %}
<tr>
<th><a href="{{ prj.get_absolute_url }}">{{ prj.name }}</a></th>
<td class="percent">{{ percent }}%</td>
<td class="progress"><div class="progress" id="{{ percent|floatformat:0 }}"></div></td>
</tr>
{% endwith %}
{% endfor %} {% endfor %}
</ul> </tbody>
</table>
{% endblock %} {% endblock %}
...@@ -83,3 +83,9 @@ td.suggestions table { ...@@ -83,3 +83,9 @@ td.suggestions table {
.helptext { .helptext {
font-size: smaller; font-size: smaller;
} }
.percent {
text-align: right;
}
div.progress {
width: 20em;
}
...@@ -18,4 +18,5 @@ $(document).ready(function(){ ...@@ -18,4 +18,5 @@ $(document).ready(function(){
}); });
$('.accordion').accordion(); $('.accordion').accordion();
$('.errorlist').addClass('ui-state-error ui-corner-all'); $('.errorlist').addClass('ui-state-error ui-corner-all');
$('div.progress').each(function f(i, e) {e = $(e); e.progressbar({ value: parseInt(e.attr('id')) })});
}); });
...@@ -3,6 +3,7 @@ from django.db.models import Q ...@@ -3,6 +3,7 @@ from django.db.models import Q
from django.contrib.auth.models import User from django.contrib.auth.models import User
from django.conf import settings from django.conf import settings
from lang.models import Language from lang.models import Language
from django.db.models import Sum
from django.utils.translation import ugettext_lazy, ugettext as _ from django.utils.translation import ugettext_lazy, ugettext as _
from django.utils.safestring import mark_safe from django.utils.safestring import mark_safe
from glob import glob from glob import glob
...@@ -51,6 +52,11 @@ class Project(models.Model): ...@@ -51,6 +52,11 @@ class Project(models.Model):
super(Project, self).save(*args, **kwargs) super(Project, self).save(*args, **kwargs)
def get_translated_percent(self):
translations = Translation.objects.filter(subproject__project = self).aggregate(Sum('translated'), Sum('total'))
return round(translations['translated__sum'] * 100.0 / translations['total__sum'], 1)
class SubProject(models.Model): class SubProject(models.Model):
name = models.CharField(max_length = 100, help_text = _('Name to display')) name = models.CharField(max_length = 100, help_text = _('Name to display'))
slug = models.SlugField(db_index = True, help_text = _('Name used in URLs')) slug = models.SlugField(db_index = True, help_text = _('Name used in URLs'))
......
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