Commit 21c112ef authored by Michal Čihař's avatar Michal Čihař

Move stats to separate page

Fixes #819
Signed-off-by: default avatarMichal Čihař <michal@cihar.com>
parent d3253e67
......@@ -8,8 +8,7 @@
{% block content %}
<div class="container-fluid">
<div class="row">
<div class="col-lg-{% if offer_hosting %}6{% else %}12{% endif %}">
<div class="panel panel-primary">
<div class="panel-heading"><h4 class="panel-title">{% trans "About Weblate" %}</h4></div>
<div class="panel-body">
......@@ -26,11 +25,9 @@
<a class="btn btn-primary" href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=AXN88S8GX5MQ4"><i class="fa fa-paypal"></i> {% trans "Donate to Weblate!" %}</a>
</div>
</div>
</div>
{% if offer_hosting %}
<div class="col-lg-6">
<div class="panel panel-primary">
<div class="panel-heading"><h4 class="panel-title">{% trans "Hosting translations" %}</h4></div>
<div class="panel-body">
......@@ -48,13 +45,9 @@
<a class="btn btn-default" href="{% url 'contact' %}?subject=Commercial hosting">{% trans "Contact us for commercial hosting" %}</a>
</div>
</div>
</div>
{% endif %}
</div>
<div class="row">
<div class="col-lg-6">
<div class="panel panel-primary">
<div class="panel-heading"><h4 class="panel-title">{% trans "Versions" %}</h4></div>
<div class="panel-body">
......@@ -67,6 +60,7 @@
<td>{{ version }}</td>
</tr>
{% for ver in versions %}
<tr>
<th><a href="{{ ver.1 }}">{{ ver.0 }}</a></th>
<td>{{ ver.2 }}</td>
</tr>
......@@ -74,51 +68,7 @@
</table>
</div>
</div>
</div>
<div class="col-lg-6">
<div class="panel panel-primary">
<div class="panel-heading"><h4 class="panel-title">{% trans "Statistics" %}</h4></div>
<div class="panel-body">
<table class="table table-condensed table-striped">
<tr>
<th>{% trans "Strings to translate" %}</th>
<td>{{ total_strings }}</td>
</tr>
<tr>
<th>{% trans "Words to translate" %}</th>
<td>{{ total_words }}</td>
</tr>
<tr>
<th>{% trans "Used languages" %}</th>
<td>{{ total_languages }}</td>
</tr>
<tr>
<th>{% trans "Registered users" %}</th>
<td>{{ total_users }}</td>
</tr>
<tr>
<th>{% trans "Suggestions made" %}</th>
<td>{{ total_suggestions }}</td>
</tr>
<tr>
<th>{% trans "Translations made" %}</th>
<td>{{ total_translations }}</td>
</tr>
<tr>
<th>{% trans "Failing checks found" %}</th>
<td>{{ total_checks }}</td>
</tr>
<tr>
<th>{% trans "Ignored checks" %}</th>
<td>{{ ignored_checks }}</td>
</tr>
</table>
</div>
</div>
</div>
</div>
</div>
{% endblock %}
......
......@@ -28,7 +28,6 @@
<li><a href="#search" data-toggle="tab">{% trans "Search" %}</a></li>
<li><a href="#history" data-toggle="tab">{% trans "History" %}</a></li>
<li><a href="#activity" data-toggle="tab" data-load="activity" data-yearly="{% url 'yearly_activity' %}" data-monthly="{% url 'monthly_activity' %}">{% trans "Activity" %}</a></li>
<li><a href="#stats" data-toggle="tab">{% trans "Statistics" %}</a></li>
<li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#">
{% trans "Tools" %} <span class="caret"></span>
......@@ -38,6 +37,7 @@
<li><a href="{% url 'checks' %}">{% trans "Checks overview" %}</a></li>
<li><a href="{% url 'data_root' %}">{% trans "Data export" %}</a></li>
<li><a href="{% url 'widgets_root' %}">{% trans "Widgets" %}</a></li>
<li><a href="{% url 'stats' %}">{% trans "Statistics" %}</a></li>
</ul>
</li>
</ul>
......@@ -100,60 +100,6 @@
{% include "activity-tab.html" %}
<div class="tab-pane" id="stats">
<div class="container-fluid">
<div class="row">
<div class="col-lg-6">
<div class="panel panel-primary">
<div class="panel-heading"><h4 class="panel-title">{% trans "Most active translators" %}</h4></div>
<div class="panel-body">
<table class="table table-condensed">
<thead>
<tr>
<th>{% trans "User" %}</th>
<th>{% trans "Translated" %}</th>
</tr>
<tbody>
{% for u in top_translations %}
<tr>
<td>{{ u.get_user_display_link }}</td>
<td class="percent">{{ u.translated }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
<div class="col-lg-6">
<div class="panel panel-primary">
<div class="panel-heading"><h4 class="panel-title">{% trans "Most active suggesters" %}</h4></div>
<div class="panel-body">
<table class="table table-condensed">
<thead>
<tr>
<th>{% trans "User" %}</th>
<th>{% trans "Suggested" %}</th>
</tr>
<tbody>
{% for u in top_suggestions %}
<tr>
<td>{{ u.get_user_display_link }}</td>
<td class="percent">{{ u.suggested }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="tab-pane" id="history">
{% include "last-changes-content.html" %}
<a class="btn btn-link" href="{% url 'changes' %}?{{ last_changes_url }}">{% trans "Browse all changes" %}</a>
......
{% extends "base.html" %}
{% load i18n %}
{% block breadcrumbs %}
<li><a href="{% url 'stats' %}">{% trans "Statistics" %}</a></li>
{% endblock %}
{% block content %}
<div class="container-fluid">
<div class="row">
<div class="col-lg-6">
<div class="panel panel-primary">
<div class="panel-heading"><h4 class="panel-title">{% trans "Most active translators" %}</h4></div>
<div class="panel-body">
<table class="table table-condensed">
<thead>
<tr>
<th>{% trans "User" %}</th>
<th>{% trans "Translated" %}</th>
</tr>
<tbody>
{% for u in top_translations %}
<tr>
<td>{{ u.get_user_display_link }}</td>
<td class="percent">{{ u.translated }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
<div class="col-lg-6">
<div class="panel panel-primary">
<div class="panel-heading"><h4 class="panel-title">{% trans "Most active suggesters" %}</h4></div>
<div class="panel-body">
<table class="table table-condensed">
<thead>
<tr>
<th>{% trans "User" %}</th>
<th>{% trans "Suggested" %}</th>
</tr>
<tbody>
{% for u in top_suggestions %}
<tr>
<td>{{ u.get_user_display_link }}</td>
<td class="percent">{{ u.suggested }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-lg-6">
<div class="panel panel-primary">
<div class="panel-heading"><h4 class="panel-title">{% trans "Statistics" %}</h4></div>
<div class="panel-body">
<table class="table table-condensed table-striped">
<tr>
<th>{% trans "Strings to translate" %}</th>
<td>{{ total_strings }}</td>
</tr>
<tr>
<th>{% trans "Words to translate" %}</th>
<td>{{ total_words }}</td>
</tr>
<tr>
<th>{% trans "Used languages" %}</th>
<td>{{ total_languages }}</td>
</tr>
<tr>
<th>{% trans "Registered users" %}</th>
<td>{{ total_users }}</td>
</tr>
<tr>
<th>{% trans "Suggestions made" %}</th>
<td>{{ total_suggestions }}</td>
</tr>
<tr>
<th>{% trans "Translations made" %}</th>
<td>{{ total_translations }}</td>
</tr>
<tr>
<th>{% trans "Failing checks found" %}</th>
<td>{{ total_checks }}</td>
</tr>
<tr>
<th>{% trans "Ignored checks" %}</th>
<td>{{ ignored_checks }}</td>
</tr>
</table>
</div>
</div>
</div>
</div>
</div>
{% endblock %}
# -*- coding: utf-8 -*-
#
# Copyright © 2012 - 2016 Michal Čihař <michal@cihar.com>
#
# This file is part of Weblate <https://weblate.org/>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
"""
Tests for data exports.
"""
from django.core.urlresolvers import reverse
from weblate.trans.tests.test_views import ViewTestCase
class BasicViewTest(ViewTestCase):
def test_about(self):
response = self.client.get(
reverse('about')
)
self.assertContains(response, 'Translate Toolkit')
def test_stats(self):
response = self.client.get(
reverse('stats')
)
self.assertContains(response, 'Weblate statistics')
......@@ -77,9 +77,3 @@ class ExportsViewTest(ViewTestCase):
reverse('data_project', kwargs=self.kw_project)
)
self.assertContains(response, 'Test')
def test_about(self):
response = self.client.get(
reverse('about')
)
self.assertContains(response, 'Translate Toolkit')
......@@ -86,8 +86,6 @@ def home(request):
)
# Some stats
top_translations = Profile.objects.order_by('-translated')[:10]
top_suggestions = Profile.objects.order_by('-suggested')[:10]
last_changes = Change.objects.last_changes(request.user)[:10]
return render(
......@@ -95,8 +93,6 @@ def home(request):
'index.html',
{
'projects': projects,
'top_translations': top_translations.select_related('user'),
'top_suggestions': top_suggestions.select_related('user'),
'last_changes': last_changes,
'last_changes_url': '',
'search_form': SiteSearchForm(),
......@@ -383,6 +379,23 @@ def about(request):
Shows about page with version information.
"""
context = {}
context['title'] = _('About Weblate')
context['versions'] = get_versions() + get_optional_versions()
return render(
request,
'about.html',
context
)
def stats(request):
"""Various stats about Weblate"""
context = {}
context['title'] = _('Weblate statistics')
totals = Profile.objects.aggregate(
Sum('translated'), Sum('suggested'), Count('id')
)
......@@ -395,7 +408,7 @@ def about(request):
total_words.append(translation.total_words)
except IndexError:
pass
context['title'] = _('About Weblate')
context['total_translations'] = totals['translated__sum']
context['total_suggestions'] = totals['suggested__sum']
context['total_users'] = totals['id__count']
......@@ -406,11 +419,16 @@ def about(request):
).distinct().count()
context['total_checks'] = Check.objects.count()
context['ignored_checks'] = Check.objects.filter(ignore=True).count()
context['versions'] = get_versions() + get_optional_versions()
top_translations = Profile.objects.order_by('-translated')[:10]
top_suggestions = Profile.objects.order_by('-suggested')[:10]
context['top_translations'] = top_translations.select_related('user')
context['top_suggestions'] = top_suggestions.select_related('user')
return render(
request,
'about.html',
'stats.html',
context
)
......
......@@ -685,6 +685,7 @@ urlpatterns = [
url(r'^contact/', weblate.accounts.views.contact, name='contact'),
url(r'^hosting/', weblate.accounts.views.hosting, name='hosting'),
url(r'^about/$', weblate.trans.views.basic.about, name='about'),
url(r'^stats/$', weblate.trans.views.basic.stats, name='stats'),
# User pages
url(
......
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