[damned-lies] Correctly color the last column on the compare stats (#685571)



commit b2778e7204ba65d29ef9ad262a302aade1091947
Author: Gil Forcada <gforcada gnome org>
Date:   Thu Oct 11 10:58:28 2012 +0200

    Correctly color the last column on the compare stats (#685571)

 stats/templatetags/stats_extras.py |   13 +++++++++++++
 templates/release_compare.html     |    2 +-
 2 files changed, 14 insertions(+), 1 deletions(-)
---
diff --git a/stats/templatetags/stats_extras.py b/stats/templatetags/stats_extras.py
index fe97f16..a56837a 100644
--- a/stats/templatetags/stats_extras.py
+++ b/stats/templatetags/stats_extras.py
@@ -26,6 +26,19 @@ def support_class(value):
     return "not_supported"
 
 @register.filter
+def support_class_total(stats):
+    """ Retuns a class depending on the trend. """
+    actual = stats['stats'][-1]
+
+    if stats['diff'] >= 0:
+        return support_class(actual)
+    else:
+        if actual >= 80:
+            return "partially"
+        else:
+            return "not_supported"
+
+ register filter
 def escapeat(value):
     """Replace '@' with '__', accepted sequence in JS ids."""
     return value.replace('@', '__')
diff --git a/templates/release_compare.html b/templates/release_compare.html
index e70ea8f..a932f8e 100644
--- a/templates/release_compare.html
+++ b/templates/release_compare.html
@@ -39,7 +39,7 @@ $(document).ready(function()
   {% for perc in stat.stats %}
     <td class="stats {{ perc|support_class }}">{{ perc }}%</td>
   {% endfor %}
-  <td class="stats {{ perc|support_class }}">{{ stat.diff }}%</td>
+  <td class="stats {{ stat|support_class_total }}">{{ stat.diff }}%</td>
 </tr>
 {% endfor %}
 </table>



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