]> ToastFreeware Gitweb - philipp/winterrodeln/wradmin.git/blob - wradmin/wradmin/lib/helpers.py
8693d70be4e9985adfa7efc0a19a04fa2f1fba75
[philipp/winterrodeln/wradmin.git] / wradmin / wradmin / lib / helpers.py
1 """Helper functions
2
3 Consists of functions to typically be used within templates, but also
4 available to Controllers. This module is available to templates as 'h'.
5 """
6 # Import helpers as desired, or define your own, ie:
7 #from webhelpers.html.tags import checkbox, password
8
9 from routes import url_for
10 import wradmin.model.validators
11 from webhelpers.html.tags import file, form, end_form, submit
12
13 def wiki(page_title=None):
14     "Creates a link to the specified page in the www.winterrodeln.org wiki"
15     if page_title is None: page_title = 'Hauptseite'
16     return u'http://www.winterrodeln.org/wiki/' + page_title
17
18
19 def forum(forum=None):
20     "Creates a link to the specified forum. If no id is given, a general link is created."
21     if forum is None: return u'http://winterrodeln-forum.org/'
22     return u'http://winterrodeln-forum.org/viewforum.php?f=%d' % forum
23
24
25 def google_maps(latitude, longitude):
26     "Builds an URL like http://maps.google.at/maps?q=47.200607,11.260007"
27     return u"http://maps.google.at/maps?q=%.6f,%.6f" % (latitude, longitude)
28
29
30 def bool(value):
31     "Takes a bool value and creates a German representation"
32     return wradmin.model.validators.GermanBool().from_python(value)
33
34
35 def tristate(yes, no):
36     "Takes a German representation of a tristate value"
37     return wradmin.model.validators.GermanTristate().from_python((yes, no))