[damned-lies] Do not show figure stats when there is no figures



commit f344b8d3dcc4e44ce9760023f953f1cfb3f665be
Author: Claude Paroz <claude 2xlibre net>
Date:   Thu Aug 4 21:39:49 2011 +0200

    Do not show figure stats when there is no figures

 stats/models.py   |    3 +++
 vertimus/views.py |    6 +++---
 2 files changed, 6 insertions(+), 3 deletions(-)
---
diff --git a/stats/models.py b/stats/models.py
index f71a88a..77656f0 100644
--- a/stats/models.py
+++ b/stats/models.py
@@ -1347,6 +1347,9 @@ class Statistics(models.Model):
                               {'messages': msg_text, 'updated': upd_text}
         return text
 
+    def has_figures(self):
+        return bool(self.full_po and self.full_po.figures)
+
     def get_figures(self):
         """ Return an enriched list of figure dicts (used in module_images.html):
             [{'path':, 'hash':, 'fuzzy':, 'translated':, 'translated_file':}, ...] """
diff --git a/vertimus/views.py b/vertimus/views.py
index 42556b5..590d3ef 100644
--- a/vertimus/views.py
+++ b/vertimus/views.py
@@ -113,13 +113,10 @@ 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,
@@ -134,6 +131,9 @@ def vertimus(request, branch, domain, language, stats=None, level="0"):
         'level': level,
         'grandparent_level': grandparent_level,
     }
+    if stats.has_figures():
+        context['fig_stats'] = stats.fig_stats()
+        del context['fig_stats']['prc']
     return render(request, 'vertimus/vertimus_detail.html', context)
 
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]