1
0
Fork 0
satnogs-db/db/base/templatetags/tags.py

25 lines
502 B
Python
Raw Normal View History

2015-07-11 12:25:16 -06:00
import re
from django import template
from django.core.urlresolvers import reverse
register = template.Library()
@register.simple_tag
def active(request, urls):
if request.path in ( reverse(url) for url in urls.split() ):
return 'active'
return None
@register.filter
def frq(value):
try:
to_format = float(value)
except TypeError:
return '-'
formatted = format(float(to_format) / 1000000, '.3f')
formatted = formatted + ' Mhz'
return formatted