[damned-lies] Better test presence of reduced stats in vertimus view



commit 91daedf2453099332a97d6dc3817a2c6a07fb656
Author: Claude Paroz <claude 2xlibre net>
Date:   Thu Mar 17 09:06:04 2011 +0100

    Better test presence of reduced stats in vertimus view

 stats/models.py                         |    3 +++
 templates/vertimus/vertimus_detail.html |    2 +-
 vertimus/views.py                       |    2 +-
 3 files changed, 5 insertions(+), 2 deletions(-)
---
diff --git a/stats/models.py b/stats/models.py
index 2c2dc8b..84d5452 100644
--- a/stats/models.py
+++ b/stats/models.py
@@ -1291,6 +1291,9 @@ class Statistics(models.Model):
     def get_translationstat(self):
         return self.full_po.translation_stat()
 
+    def has_reducedstat(self):
+        return bool(self.part_po is not None and self.part_po != self.full_po)
+
     def get_reducedstat(self):
         return self.part_po.translation_stat()
 
diff --git a/templates/vertimus/vertimus_detail.html b/templates/vertimus/vertimus_detail.html
index 30fb373..4589e40 100644
--- a/templates/vertimus/vertimus_detail.html
+++ b/templates/vertimus/vertimus_detail.html
@@ -70,7 +70,7 @@ $(document).ready(function() {
       <div class="untranslated" style="{{ LANGUAGE_BIDI|yesno:"right,left" }}:{{ stats.tr_percentage|add:stats.fu_percentage }}px; width: {{ stats.un_percentage }}px;"></div>
     </div>
   </div>
-  {% if stats.part_po != stats.full_po %}
+  {% if po_url_reduced %}
   <div style="float:left; margin-left: 150px;">
     <a href="{{ po_url_reduced }}"><img src="{{ MEDIA_URL }}img/download.png" alt="{% trans "Download PO file" %}" /></a> {% trans "Translated (reduced):" %}
     {{ stats.get_reducedstat|safe }}&nbsp;
diff --git a/vertimus/views.py b/vertimus/views.py
index c618b57..ea35c2e 100644
--- a/vertimus/views.py
+++ b/vertimus/views.py
@@ -125,7 +125,7 @@ def vertimus(request, branch, domain, language, stats=None, level="0"):
         'stats': stats,
         'pot_stats': pot_stats,
         'po_url': po_url,
-        'po_url_reduced': stats.part_po and stats.po_url(reduced=True) or None,
+        'po_url_reduced': stats.has_reducedstat() and stats.po_url(reduced=True) or '',
         'branch': branch,
         'other_states': other_branch_states,
         'domain': domain,



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