bornhack-website/shop/templatetags/shop_tags.py
Thomas Steen Rasmussen ed79b8f73a misc. invoice fixes
2016-05-31 06:51:42 +02:00

23 lines
525 B
Python

from django import template
from django.utils.safestring import mark_safe
from decimal import Decimal
register = template.Library()
@register.filter
def currency(value):
try:
return "{0:.2f} DKK".format(Decimal(value))
except ValueError:
return False
@register.filter()
def truefalseicon(value):
if value:
return mark_safe("<span class='text-success glyphicon glyphicon-ok'></span>")
else:
return mark_safe("<span class='text-danger glyphicon glyphicon-remove'></span>")