1 from flask import url_for
2 import wrpylib.wrvalidators
6 def url(self, filename=None, controller=None, action=None, **kwargs):
7 if filename is not None and filename.startswith('/'):
8 filename = filename[1:]
9 return url_for('static', filename=filename)
10 if controller == 'rodelbahn':
12 return url_for('index')
13 return url_for('{}_{}'.format(controller, action), **kwargs)
15 def wiki(self, page_title=None):
16 """Creates a link to the specified page in the www.winterrodeln.org wiki"""
17 if page_title is None:
18 page_title = 'Hauptseite'
19 return 'https://www.winterrodeln.org/wiki/' + page_title
21 def forum(self, forum=None):
22 """Creates a link to the specified forum. If no id is given, a general link is created."""
24 return 'http://winterrodeln-forum.org/'
25 return 'https://winterrodeln-forum.org/viewforum.php?f={}'.format(forum)
27 def google_maps(self, latitude, longitude):
28 """Builds an URL like http://maps.google.at/maps?q=47.200607,11.260007"""
29 return "https://maps.google.at/maps?q=%.6f,%.6f" % (latitude, longitude)
31 def bool(self, value):
32 """Takes a bool value and creates a German representation"""
33 return wrpylib.wrvalidators.opt_bool_german_to_str(value)
35 def tristate_tuple(self, yes, no):
36 """Takes a German representation of a tristate value"""
37 return {(True, True): 'Teilweise', (True, False): 'Ja', (False, True): 'Nein'}.get((yes, no), None)
39 def tristate_float(self, value):
40 """Takes a German representation of a tristate value"""
41 return wrpylib.wrvalidators.opt_tristate_german_to_str(value)
43 def public_transport(self, value):
44 return wrpylib.wrvalidators.opt_public_transport_german_to_str(value)