Commit 8bb0f62b authored by Michal Čihař's avatar Michal Čihař

Add forms for words and strings reports

Fixes #835
Signed-off-by: default avatarMichal Čihař <michal@cihar.com>
parent 3b84b41f
......@@ -194,13 +194,15 @@
{% if user_can_view_reports %}
<div class="tab-pane" id="reports">
<div class="row">
<div class="col-lg-6">
<form action="{% url 'credits' project=object.subproject.project.slug subproject=object.subproject.slug %}" method="post" enctype="multipart/form-data">
<div class="panel panel-primary">
<div class="panel-heading"><h4 class="panel-title">{% trans "Credits" %}</h4></div>
<div class="panel-body">
<p>{% trans "Credits list all translators who have contributed to this component in given time period. It can be useful for including in your documentation or application to thanks to translators." %}</p>
{% csrf_token %}
{{ credits_form|crispy }}
{{ reports_form|crispy }}
</div>
<div class="panel-footer">
<input type="submit" value="{% trans "Generate" %}" class="btn btn-default" />
......@@ -208,6 +210,23 @@
</div>
</form>
</div>
<div class="col-lg-6">
<form action="{% url 'counts' project=object.subproject.project.slug subproject=object.subproject.slug %}" method="post" enctype="multipart/form-data">
<div class="panel panel-primary">
<div class="panel-heading"><h4 class="panel-title">{% trans "Contributor stats" %}</h4></div>
<div class="panel-body">
<p>{% trans "Reports number of strings and words translated by each translator." %}</p>
{% csrf_token %}
{{ reports_form|crispy }}
</div>
<div class="panel-footer">
<input type="submit" value="{% trans "Generate" %}" class="btn btn-default" />
</div>
</div>
</form>
</div>
</div>
</div>
{% endif %}
{% if perms.trans.upload_translation %}
......
......@@ -812,7 +812,7 @@ class UserManageForm(forms.Form):
raise ValidationError(_('More users matched!'))
class ReportDownloadForm(forms.Form):
class ReportsForm(forms.Form):
style = forms.ChoiceField(
label=_('Report format'),
help_text=_('Choose file format for the report'),
......@@ -846,7 +846,3 @@ class ReportDownloadForm(forms.Form):
format='%Y-%m-%d'
)
)
class CreditsForm(ReportDownloadForm):
pass
......@@ -36,7 +36,7 @@ from weblate.lang.models import Language
from weblate.trans.forms import (
get_upload_form, SearchForm,
AutoForm, ReviewForm, NewLanguageForm,
UserManageForm, CreditsForm,
UserManageForm, ReportsForm,
)
from weblate.trans.permissions import can_automatic_translation
from weblate.accounts.models import Profile, notify_new_language
......@@ -314,7 +314,7 @@ def show_translation(request, project, subproject, lang):
'search_form': search_form,
'review_form': review_form,
'last_changes': last_changes,
'credits_form': CreditsForm(),
'reports_form': ReportsForm(),
'last_changes_url': urlencode(obj.get_kwargs()),
'show_only_component': True,
'other_translations': Translation.objects.filter(
......
......@@ -19,7 +19,7 @@
#
from weblate.trans.models.changes import Change
from weblate.trans.forms import CreditsForm
from weblate.trans.forms import ReportsForm
from weblate.trans.views.helper import get_subproject
from weblate.trans.permissions import can_view_reports
from django.http import HttpResponse
......@@ -58,7 +58,7 @@ def get_credits(request, project, subproject):
if not can_view_reports(request.user, obj.project):
raise PermissionDenied()
form = CreditsForm(request.POST)
form = ReportsForm(request.POST)
if not form.is_valid():
return redirect(obj)
......@@ -159,7 +159,7 @@ def get_counts(request, project, subproject):
if not can_view_reports(request.user, obj.project):
raise PermissionDenied()
form = CreditsForm(request.POST)
form = ReportsForm(request.POST)
if not form.is_valid():
return redirect(obj)
......@@ -177,7 +177,10 @@ def get_counts(request, project, subproject):
)
if form.cleaned_data['style'] == 'html':
start = '<table>'
start = (
'<table>\n<tr><th>Email</th><th>Name</th>'
'<th>Words</th><th>Count</th></tr>'
)
row_start = '<tr>'
cell_format = u'<td>{0}</td>\n'
row_end = '</tr>'
......
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