remove unnecessary imports
[mygpo.git] / mygpo / web / templatetags / utils.py
bloba335486da37979afe1f9fb978e806549a3b56af3
1 from django import template
2 from django.utils.safestring import mark_safe
3 from mygpo.web.utils import get_page_list
5 register = template.Library()
7 @register.filter
8 def lookup(dic, key):
9 return mark_safe(dic.get(key, ''))
11 @register.filter
12 def lookup_list(dict, keys):
13 for key in keys:
14 if key in dict:
15 yield dict[key]
18 @register.simple_tag
19 def smartwidthratio(val, max_val, upper, lower):
20 return max(lower, (float(val) / max_val * upper))
22 @register.filter
23 def page_list(cur, start, total, show_max):
24 return get_page_list(start, total, cur, show_max)
27 @register.filter
28 def filter_dict(dic):
29 return [key for key, val in dic.iteritems() if val]
32 @register.filter
33 def append(l, item):
34 return l + [item]
36 @register.filter
37 def remove(l, item):
38 return [x for x in l if x != item]