Commit a62c3d52 authored by Claude Paroz's avatar Claude Paroz

Clean module_image and reuse num_stats template tag

parent c02988e6
......@@ -2,7 +2,7 @@ from django import template
from django.utils.safestring import mark_safe
from django.utils.translation import get_language_bidi
from stats.models import PoFile
from stats.models import PoFile, Statistics, FakeStatistics
register = template.Library()
......@@ -38,10 +38,16 @@ def browse_bugs(module, content):
@register.filter
def num_stats(stat, scope='full'):
""" Produce stat numbers as in: 85% (1265/162/85) """
return mark_safe("%s%% (%s/%s/%s)" % (
stat.tr_percentage(scope), stat.translated(scope),
stat.fuzzy(scope), stat.untranslated(scope))
)
if isinstance(stat, (Statistics, FakeStatistics)):
stats = {
'prc': stat.tr_percentage(scope),
'translated': stat.translated(scope),
'fuzzy': stat.fuzzy(scope),
'untranslated': stat.untranslated(scope),
}
else:
stats = stat
return mark_safe("%(prc)s%% (%(translated)s/%(fuzzy)s/%(untranslated)s)" % stats)
@register.filter
def vis_stats(stat, scope='full'):
......
......@@ -156,9 +156,11 @@ def docimages(request, module_name, potbase, branch_name, langcode):
branch = get_object_or_404(Branch, module__pk=mod.id, name=branch_name)
stat = FakeStatistics(mod, branch, 'doc', lang)
context = {
'pageSection': "module",
'module': mod,
'stat': stat
'pageSection': "module",
'module': mod,
'stat': stat,
'locale': stat.language.locale,
'figstats': stat.fig_stats(),
}
return render(request, 'module_images.html', context)
......
{% extends "base.html" %}
{% load i18n %}
{% load i18n stats_extras %}
{% block title %} {% blocktrans with module.description as name %}Module Doc Figure Status: {{ name }}{% endblocktrans %} {% endblock %}
......@@ -8,15 +8,12 @@
<h1><a href="{% url stats.views.module module.name %}">{{ module.description }}</a> {% trans stat.domain.description %} ({% trans stat.language.name %})</h1>
{% with stat.fig_stats as figstat %}
<h2>{% trans "Figures translation status" %} &mdash;
<small>{{ figstat.prc }}% ({{ figstat.translated }}/{{ figstat.fuzzy}}/{{ figstat.untranslated }})</small></h2>
{% endwith %}
<small>{{ figstats|num_stats }}</small></h2>
<table class="stats">
<thead><tr><th width="50%">{% trans "Original" %}</th><th width="50%">{% trans stat.language.name %}</th></tr></thead>
{% for fig in stat.get_figures %}
{% with stat.language.locale as locale %}
<tr><td valign="top">
<a href="{{ fig.orig_remote_url }}"><span class="path">C/{{ fig.path }}</span><br/></a>
{% if fig.video %}<video src="{{ fig.orig_remote_url }}" controls></video>
......@@ -51,7 +48,6 @@
{% endif %}
</td>
</tr>
{% endwith %}
{% endfor %}
</table>
......
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