Commit e8762dc0 authored by Claude Paroz's avatar Claude Paroz

Display image stats on vertimus detail page (Fixes #650564)

parent 01234d5c
......@@ -1197,7 +1197,7 @@ class PoFile(models.Model):
def fig_count(self):
""" If stat of a document type, get the number of figures in the document """
return len(self.figures)
return self.figures and len(self.figures) or 0
def tr_percentage(self):
if self.pot_size() == 0:
......
......@@ -47,7 +47,11 @@ def num_stats(stat, scope='full'):
}
else:
stats = stat
return mark_safe("%(prc)s%% (%(translated)s/%(fuzzy)s/%(untranslated)s)" % stats)
if 'prc' in stats:
model = "%(prc)s%% (%(translated)s/%(fuzzy)s/%(untranslated)s)"
else:
model = "(%(translated)s/%(fuzzy)s/%(untranslated)s)"
return mark_safe(model % stats)
@register.filter
def vis_stats(stat, scope='full'):
......
......@@ -78,10 +78,10 @@ $(document).ready(function() {
</div>
</div>
{% endif %}
{% if pot_stats.full_po.fig_count and stats.language %}
{% if fig_stats and stats.language %}
<div class="docimages">
<a href="{% url stats.views.docimages module_name=module.name,potbase=stats.domain.name,branch_name=branch.name,langcode=stats.language.locale %}">
<img src="{{ MEDIA_URL }}img/figure.png" alt="{% trans "Display document figures" %}"></a>
{% url stats.views.docimages module_name=module.name,potbase=stats.domain.name,branch_name=branch.name,langcode=stats.language.locale as img_url %}
{% blocktrans with stats=fig_stats|num_stats count total=fig_stats.total %} including <a href="{{ img_url }}">{{ stats }} image</a>{% plural %} including <a href="{{ img_url }}">{{ stats }} images</a>{% endblocktrans %}
</div>
{% endif %}
</div>
......
......@@ -113,10 +113,13 @@ def vertimus(request, branch, domain, language, stats=None, level="0"):
else:
action_form = None
fig_stats = stats.fig_stats()
del fig_stats['prc']
context = {
'pageSection': 'module',
'stats': stats,
'pot_stats': pot_stats,
'fig_stats': fig_stats,
'po_url': stats.po_url(),
'po_url_reduced': stats.has_reducedstat() and stats.po_url(reduced=True) or '',
'branch': branch,
......
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