summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mirrors/templatetags/mirror_status.py11
-rw-r--r--templates/mirrors/mirror_details.html6
-rw-r--r--templates/mirrors/mirrorlist_status.txt4
-rw-r--r--templates/mirrors/status_table.html6
4 files changed, 16 insertions, 11 deletions
diff --git a/mirrors/templatetags/mirror_status.py b/mirrors/templatetags/mirror_status.py
index 9a363fb..b3810d9 100644
--- a/mirrors/templatetags/mirror_status.py
+++ b/mirrors/templatetags/mirror_status.py
@@ -1,6 +1,5 @@
from datetime import timedelta
from django import template
-from django.template.defaultfilters import floatformat
register = template.Library()
@@ -27,10 +26,16 @@ def hours(value):
return '%d hours' % hrs
@register.filter
-def percentage(value, arg=-1):
+def floatvalue(value, arg=2):
+ if value is None:
+ return u''
+ return '%.*f' % (arg, value)
+
+@register.filter
+def percentage(value, arg=1):
if not value and type(value) != float:
return u''
new_val = value * 100.0
- return floatformat(new_val, arg) + '%'
+ return '%.*f%%' % (arg, new_val)
# vim: set ts=4 sw=4 et:
diff --git a/templates/mirrors/mirror_details.html b/templates/mirrors/mirror_details.html
index f2ffce2..e1962b8 100644
--- a/templates/mirrors/mirror_details.html
+++ b/templates/mirrors/mirror_details.html
@@ -110,9 +110,9 @@
<td>{{ m_url.last_sync|date:'Y-m-d H:i'|default:'unknown' }}</td>
<td>{{ m_url.completion_pct|percentage:1 }}</td>
<td>{{ m_url.delay|duration|default:'unknown' }}</td>
- <td>{{ m_url.duration_avg|floatformat:2 }}</td>
- <td>{{ m_url.duration_stddev|floatformat:2 }}</td>
- <td>{{ m_url.score|floatformat:1|default:'∞' }}</td>
+ <td>{{ m_url.duration_avg|floatvalue:2 }}</td>
+ <td>{{ m_url.duration_stddev|floatvalue:2 }}</td>
+ <td>{{ m_url.score|floatvalue:1|default:'∞' }}</td>
</tr>
{% endfor %}
</tbody>
diff --git a/templates/mirrors/mirrorlist_status.txt b/templates/mirrors/mirrorlist_status.txt
index 575d19f..c69075a 100644
--- a/templates/mirrors/mirrorlist_status.txt
+++ b/templates/mirrors/mirrorlist_status.txt
@@ -1,4 +1,4 @@
-{% comment %}
+{% load mirror_status %}{% comment %}
Yes, ugly templates are ugly, but in order to keep line breaks where we want
them, sacrifices have to be made. If editing this template, it is easiest to
forget about where line breaks are happening until you are done getting the
@@ -9,6 +9,6 @@ content right, and then go back later to fix it all up.
## Generated on {% now "Y-m-d" %}
##
{% for mirror_url in mirror_urls %}
-## Score: {{ mirror_url.score|floatformat:1|default:'unknown' }}, {{ mirror_url.country.name|default:'Worldwide' }}
+## Score: {{ mirror_url.score|floatvalue:1|default:'unknown' }}, {{ mirror_url.country.name|default:'Worldwide' }}
#Server = {{ mirror_url.url}}$repo/os/$arch{% endfor %}
{% endautoescape %}
diff --git a/templates/mirrors/status_table.html b/templates/mirrors/status_table.html
index 6fc07a3..00b9c1d 100644
--- a/templates/mirrors/status_table.html
+++ b/templates/mirrors/status_table.html
@@ -20,9 +20,9 @@
<td class="country">{% country_flag m_url.country %}{{ m_url.country.name }}</td>
<td>{{ m_url.completion_pct|percentage:1 }}</td>
<td>{{ m_url.delay|duration|default:'unknown' }}</td>
- <td>{{ m_url.duration_avg|floatformat:2 }}</td>
- <td>{{ m_url.duration_stddev|floatformat:2 }}</td>
- <td>{{ m_url.score|floatformat:1|default:'∞' }}</td>
+ <td>{{ m_url.duration_avg|floatvalue:2 }}</td>
+ <td>{{ m_url.duration_stddev|floatvalue:2 }}</td>
+ <td>{{ m_url.score|floatvalue:1|default:'∞' }}</td>
</tr>{% endfor %}
</tbody>
</table>