Show some user stats

This commit is contained in:
Michal Čihař 2012-03-05 13:55:09 +01:00
parent fa0ff95e65
commit d17ebb1475
2 changed files with 45 additions and 0 deletions

View File

@ -24,5 +24,44 @@
</tbody> </tbody>
</table> </table>
<h2>{% trans "Users" %}</h2>
<h3>{% trans "Best translators" %}</h3>
<table>
<thead>
<tr>
<th>{% trans "User" %}</th>
<th>{% trans "Translated" %}</th>
</tr>
<tbody>
{% for u in top_translations %}
<tr>
<td>{{ u.user.get_full_name }}</td>
<td class="percent">{{ u.translated }}</td>
</tr>
{% endfor %}
</tbody>
</table>
<h3>{% trans "Best suggestions" %}</h3>
<table>
<thead>
<tr>
<th>{% trans "User" %}</th>
<th>{% trans "Suggested" %}</th>
</tr>
<tbody>
{% for u in top_suggestions %}
<tr>
<td>{{ u.user.get_full_name }}</td>
<td class="percent">{{ u.suggested }}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endblock %} {% endblock %}

View File

@ -11,6 +11,7 @@ from django.contrib.auth.models import AnonymousUser
from trans.models import Project, SubProject, Translation, Unit, Suggestion from trans.models import Project, SubProject, Translation, Unit, Suggestion
from trans.forms import TranslationForm, UploadForm from trans.forms import TranslationForm, UploadForm
from util import is_plural, split_plural, join_plural from util import is_plural, split_plural, join_plural
from accounts.models import Profile
import logging import logging
import os.path import os.path
@ -19,8 +20,13 @@ logger = logging.getLogger('weblate')
def home(request): def home(request):
projects = Project.objects.all() projects = Project.objects.all()
top_translations = Profile.objects.order_by('-translated')[:10]
top_suggestions = Profile.objects.order_by('-suggested')[:10]
return render_to_response('index.html', RequestContext(request, { return render_to_response('index.html', RequestContext(request, {
'projects': projects, 'projects': projects,
'top_translations': top_translations,
'top_suggestions': top_suggestions,
'title': settings.SITE_TITLE, 'title': settings.SITE_TITLE,
})) }))