summaryrefslogtreecommitdiffstats
path: root/mirrors/templatetags
diff options
context:
space:
mode:
authorjelle van der Waa <jelle@vdwaa.nl>2018-01-29 20:10:10 +0100
committerAngel Velásquez <angvp@archlinux.org>2018-01-29 14:10:10 -0500
commit148692cd8fc79b3e43ef0f2c40a2da9d87c9da9e (patch)
treed34782a388091c4f14b24b9d0878f4a8265beef2 /mirrors/templatetags
parent2ff2b26aa92c8efd21090562091361924a3a9428 (diff)
downloadarchweb-148692cd8fc79b3e43ef0f2c40a2da9d87c9da9e.tar.gz
archweb-148692cd8fc79b3e43ef0f2c40a2da9d87c9da9e.zip
More code refactoring / tests (#79)
* main: move tests to main/tests Move the templatetags tests to main/tests/test_templatetags. * main: Add test for templatetags country Create a test for the templatetag country_flag. * main: remove duplicate floatvalue floatvalue is only used in the mirrors templates and the same exact function exists in the mirror_status templatetags. * main: Remove duplicate hours filter The hours filter is also defined in the mirror_status and only used in mirrors. * main: move percentage filter to mirrors Move the percentage filter to the only user of it and add a test for basic use cases. * main: remove duplicate duration implementation The duration templatetag filter is also defined in mirror_status.py * templates: remove unrequired import flags * main: Add missing testcase for country_flag Add the None test case, so that the function is fully covered. * todolists: create tests for Todolist model Add basic tests for the Todolist model
Diffstat (limited to 'mirrors/templatetags')
-rw-r--r--mirrors/templatetags/mirror_status.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/mirrors/templatetags/mirror_status.py b/mirrors/templatetags/mirror_status.py
index c8004e4b..b3810d9a 100644
--- a/mirrors/templatetags/mirror_status.py
+++ b/mirrors/templatetags/mirror_status.py
@@ -31,4 +31,11 @@ def floatvalue(value, arg=2):
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 '%.*f%%' % (arg, new_val)
+
# vim: set ts=4 sw=4 et: