[damned-lies] Display image stats on vertimus detail page (Fixes #650564)
- From: Claude Paroz <claudep src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [damned-lies] Display image stats on vertimus detail page (Fixes #650564)
- Date: Thu, 4 Aug 2011 13:12:17 +0000 (UTC)
commit e8762dc000759909cbe176789cf9412f8568e92b
Author: Claude Paroz <claude 2xlibre net>
Date: Thu Aug 4 15:10:54 2011 +0200
Display image stats on vertimus detail page (Fixes #650564)
stats/models.py | 2 +-
stats/templatetags/stats_extras.py | 6 +++++-
templates/vertimus/vertimus_detail.html | 6 +++---
vertimus/views.py | 3 +++
4 files changed, 12 insertions(+), 5 deletions(-)
---
diff --git a/stats/models.py b/stats/models.py
index 311e62e..7a7aa66 100644
--- a/stats/models.py
+++ b/stats/models.py
@@ -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:
diff --git a/stats/templatetags/stats_extras.py b/stats/templatetags/stats_extras.py
index 0c6dac9..1612a02 100644
--- a/stats/templatetags/stats_extras.py
+++ b/stats/templatetags/stats_extras.py
@@ -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'):
diff --git a/templates/vertimus/vertimus_detail.html b/templates/vertimus/vertimus_detail.html
index f0e10a9..11d45b8 100644
--- a/templates/vertimus/vertimus_detail.html
+++ b/templates/vertimus/vertimus_detail.html
@@ -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>
diff --git a/vertimus/views.py b/vertimus/views.py
index 69d84ec..42556b5 100644
--- a/vertimus/views.py
+++ b/vertimus/views.py
@@ -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,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]