bt.py 744 Bytes
Newer Older
1
2
3
4
from django.template import Library, Variable
from django.conf import settings
from django import template
import random
5
from nnmon.bt.models import COUNTRIES, STATUS, TYPES, MEDIA
6
7
8
9
10
11
12
13
14
15
16

register = Library()

@register.simple_tag
def root_url():
    return settings.ROOT_URL

@register.simple_tag
def media_url():
    return settings.MEDIA_URL

stef's avatar
stef committed
17
18
19
20
country_map=dict(COUNTRIES)
@register.filter(name='country')
def country(code):
    return country_map[code]
stef's avatar
stef committed
21
22
23
24
25

status_map=dict(STATUS)
@register.filter(name='status')
def status(code):
    return status_map[code]
26

27
28
29
30
type_map=dict(TYPES)
@register.filter(name='type')
def type(code):
    return type_map[code]
31
32
33
34
35

media_map=dict(MEDIA)
@register.filter(name='media')
def media(code):
    return media_map[code]