]> ToastFreeware Gitweb - philipp/winterrodeln/wradmin.git/blob - wradmin/__init__.py
fba490dd6aabb5bc8906d4e2d6f1831d50977919
[philipp/winterrodeln/wradmin.git] / wradmin / __init__.py
1 from flask import Flask, send_from_directory, abort, g, render_template
2 from sqlalchemy.engine import create_engine
3 import wradmin.model
4 import wradmin.template_helper
5 from wradmin.controllers.rodelbahn import RodelbahnController
6 from wradmin.controllers.gasthaus import GasthausController
7 from wradmin.controllers.bericht import BerichtController
8 from wradmin.controllers.coordtool import CoordtoolController
9
10
11 app = Flask(__name__)
12 app.config.from_envvar('WRADMIN_SETTINGS')
13 wradmin.model.init_model(create_engine(app.config['DATABASE_URI']))
14 app.jinja_env.globals.update(h=wradmin.template_helper.PylonsHelper())
15
16
17 @app.teardown_appcontext
18 def remove_db_session(error):
19     """Removes the database session at the end of the request."""
20     wradmin.model.meta.Session.remove()
21
22
23 @app.route("/")
24 def index():
25     return render_template('index.html')
26
27
28 @app.route("/rodelbahn/list")
29 def rodelbahn_list():
30     return RodelbahnController().list()
31
32
33 @app.route("/rodelbahn/view/<int:id>")
34 def rodelbahn_view(id):
35     return RodelbahnController().view(id)
36
37
38 @app.route("/rodelbahn/update")
39 def rodelbahn_update():
40     return RodelbahnController().update()
41
42
43 @app.route("/rodelbahn/update_regioncache")
44 def rodelbahn_update_regioncache():
45     return RodelbahnController().update_regioncache()
46
47
48 @app.route("/bericht/list")
49 def bericht_list():
50     return BerichtController().list()
51
52
53 @app.route("/bericht/view/<int:id>")
54 def bericht_view(id):
55     return BerichtController().view(id)
56
57
58 @app.route("/bericht/change_date_invalid/<int:id>", methods=['POST'])
59 def bericht_change_date_invalid(id):
60     return BerichtController().change_date_invalid(id)
61
62
63 @app.route("/gasthaus/list")
64 def gasthaus_list():
65     return GasthausController().list()
66
67
68 @app.route("/gasthaus/view/<int:id>")
69 def gasthaus_view(id):
70     return GasthausController().view(id)
71
72
73 @app.route("/gasthaus/update")
74 def gasthaus_update():
75     return GasthausController().update()
76
77
78 @app.route("/coordtool/index")
79 def coordtool_index():
80     return CoordtoolController().index()
81
82
83 @app.route("/coordtool/convert", methods=['POST'])
84 def coordtool_convert():
85     return CoordtoolController().convert()