1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Cleaned up logic for calculating power draw

This commit is contained in:
Jeremy Stretch
2019-06-19 10:51:53 -04:00
parent ce9f7a8ddc
commit 1a5aaf54dd
7 changed files with 108 additions and 88 deletions

View File

@@ -166,6 +166,22 @@ def fgcolor(value):
return '#{}'.format(foreground_color(value))
@register.filter()
def divide(x, y):
"""
Return x/y (rounded).
"""
return round(x / y)
@register.filter()
def percentage(x, y):
"""
Return x/y as a percentage.
"""
return round(x / y * 100)
#
# Tags
#