comparison sat_website/templatetags/utils.py @ 46:a18800261cf6

change some texts, add a couple of screenshots, set metadata version and year to the medias
author souliane <souliane@mailoo.org>
date Wed, 29 Apr 2015 13:04:15 +0200
parents 9d553570cc61
children 3d04a955bec4
comparison
equal deleted inserted replaced
45:62c23067e86e 46:a18800261cf6
1 from django import template 1 from django import template
2 from django.forms import RadioSelect, CheckboxInput 2 from django.forms import RadioSelect, CheckboxInput
3 from django.utils.translation import get_language, ugettext_lazy
3 register = template.Library() 4 register = template.Library()
4 5
5 @register.filter 6 @register.filter
6 def is_tuple(value): 7 def is_tuple(value):
7 """Tell if this value is a tuple or not. 8 """Tell if this value is a tuple or not.
65 index = 0 66 index = 0
66 while index < len(value): 67 while index < len(value):
67 result.append(value[index:index + n]) 68 result.append(value[index:index + n])
68 index += n 69 index += n
69 return result 70 return result
71
72 @register.filter
73 def metadata(data):
74 """Return a string representation of a metadata dict.
75
76 @param data (dict{__proxy__: unicode}): metadata dictionnary
77 @return: unicode
78 """
79 if not data:
80 return ""
81 lang = get_language()
82 sep = ugettext_lazy(': ')
83 items = ["%s%s%s" % (key.translate(lang), sep, value) for key, value in data.iteritems()]
84 return "(%s)" % ', '.join(items)