Math filters that've been in use for a bit now

This commit is contained in:
Correl Roush 2010-09-22 00:52:15 -04:00
parent 80516e21d5
commit 59d4351565

View file

@ -0,0 +1,27 @@
from django.template import Library
register = Library()
@register.filter
def mult(value, arg):
"Multiplies the arg and the value"
return int(value) * int(arg)
@register.filter
def sub(value, arg):
"Subtracts the arg from the value"
return int(value) - int(arg)
@register.filter
def div(value, arg):
"Divides the value by the arg"
return int(value) / int(arg)
@register.filter
def getsum(value):
if type(value) == dict:
return sum(value.values())
elif type(value) == list:
return sum(value)
else:
return 0