4 """This module contains code to make tha access of winterrodeln
5 tables in MediaWiki easy. The module uses sqlalchemy to access the database.
7 from sqlalchemy import Table, Column, types, schema
8 from sqlalchemy.dialects.mysql import ENUM
11 intermaps_sledrun_id_type = types.Unicode(50)
12 intermaps_sledrun_status_type = ENUM('open', 'closed', 'in_preparation', 'unknown')
15 def wrreport_table(metadata):
16 """Returns the sqlalchemy Table representing the "wrreport" Winterrodeln table in MediaWiki.
17 Current table definition.
19 * version 1.3 (no changes)
20 * version 1.4 (no changes)
21 * version 1.5 added time_report
22 :param metadata: metadata = sqlalchemy.MetaData()
24 return Table("wrreport", metadata,
25 Column("id", types.Integer, primary_key=True),
26 Column("page_id", types.Integer, schema.ForeignKey('wrsledruncache.page_id')),
27 Column("page_title", types.Unicode(255), nullable=False),
28 Column("date_report", types.Date),
29 Column("time_report", types.Time),
30 Column("date_entry", types.DateTime, nullable=False),
31 Column("date_invalid", types.DateTime),
32 Column("condition", types.Integer),
33 Column("description", types.Unicode),
34 Column("author_name", types.Unicode(30)),
35 Column("author_ip", types.Unicode(15)),
36 Column("author_userid", types.Integer),
37 Column("author_username", types.Unicode(30)),
38 Column("delete_date", types.DateTime),
39 Column("delete_person_name", types.Unicode(30)),
40 Column("delete_person_ip", types.Unicode(15)),
41 Column("delete_person_userid", types.Integer),
42 Column("delete_person_username", types.Unicode(30)),
43 Column("delete_reason_public", types.Unicode),
44 Column("delete_invisible", types.Boolean),
48 def wrsledruncache_table(metadata):
49 """Returns the sqlalchemy Table representing the "wrsledruncache" Winterrodeln table in MediaWiki.
50 Current table definition
51 * version 1.4 (renamed table and added column walkup_possible)
52 :param metadata: metadata = sqlalchemy.MetaData()
54 return Table("wrsledruncache", metadata,
55 Column("page_id", types.Integer, schema.ForeignKey('wrreportcache.page_id'), primary_key=True),
56 Column("page_title", types.Unicode(255)),
57 Column("name_url", types.Unicode(255)),
58 Column("position_latitude", types.Float),
59 Column("position_longitude", types.Float),
60 Column("top_latitude", types.Float),
61 Column("top_longitude", types.Float),
62 Column("top_elevation", types.Integer),
63 Column("bottom_latitude", types.Float),
64 Column("bottom_longitude", types.Float),
65 Column("bottom_elevation", types.Integer),
66 Column("length", types.Integer),
67 Column("difficulty", types.Integer),
68 Column("avalanches", types.Integer),
69 Column("operator", types.Unicode(255)),
70 Column("public_transport", types.Integer),
71 Column("walkup_possible", types.Boolean),
72 Column("walkup_time", types.Integer),
73 Column("walkup_separate", types.Float),
74 Column("walkup_separate_comment", types.Unicode(255)),
75 Column("lift", types.Boolean),
76 Column("lift_details", types.Unicode(255)),
77 Column("night_light", types.Float),
78 Column("night_light_comment", types.Unicode(255)),
79 Column("night_light_days", types.Integer),
80 Column("night_light_days_comment", types.Unicode(255)),
81 Column("sled_rental", types.Boolean),
82 Column("sled_rental_comment", types.Unicode(255)),
83 Column("cachet", types.Unicode(255)),
84 Column("information_web", types.Unicode(255)),
85 Column("information_phone", types.Unicode(255)),
86 Column("image", types.Unicode(255)),
87 Column("show_in_overview", types.Boolean),
88 Column("forum_id", types.Integer),
89 Column("under_construction", types.Boolean),
93 def wrinncache_table(metadata):
94 """Returns the sqlalchemy Table representing the "wrinncache" Winterrodeln table in MediaWiki.
95 Current table definition
96 * version 1.3 (changes made from version 1.2)
97 * version 1.4 (no changes)
98 :param metadata: metadata = sqlalchemy.MetaData()
100 return Table("wrinncache", metadata,
101 Column("page_id", types.Integer, primary_key=True),
102 Column("page_title", types.Unicode(255)),
103 Column("position_latitude", types.Float),
104 Column("position_longitude", types.Float),
105 Column("position_elevation", types.Integer),
106 Column("operator", types.Unicode(255)),
107 Column("seats", types.Integer),
108 Column("overnight", types.Boolean),
109 Column("overnight_comment", types.Unicode(255)),
110 Column("smoker_area", types.Boolean),
111 Column("nonsmoker_area", types.Boolean),
112 Column("sled_rental", types.Boolean),
113 Column("sled_rental_comment", types.Unicode(255)),
114 Column("mobile_provider", types.Unicode),
115 Column("homepage", types.Unicode(255)),
116 Column("email_list", types.Unicode),
117 Column("phone_list", types.Unicode),
118 Column("image", types.Unicode(255)),
119 Column("sledding_list", types.Unicode),
120 Column("under_construction", types.Boolean),
124 def wrreportcache_table(metadata):
125 """Returns the sqlalchemy Table representing the "wrreportcache" Winterrodeln table in MediaWiki.
126 Current table definition.
127 * version 1.5 (introduction)
128 :param metadata: metadata = sqlalchemy.MetaData()
130 return Table("wrreportcache", metadata,
131 Column("page_id", types.Integer, primary_key=True),
132 Column("page_title", types.Unicode(255), nullable=False),
133 Column("report_id", types.Integer, schema.ForeignKey('wrreport.id')),
134 Column("date_report", types.Date),
135 Column("condition", types.Integer),
136 Column("description", types.Unicode),
137 Column("author_name", types.Unicode(30)),
138 Column("author_username", types.Unicode(30))
142 def wrregion_table(metadata):
143 """Returns the sqlalchemy Table representing the "wrregion" Winterrodeln table in MediaWiki.
144 Current table definition.
145 * version 1.5 (introduction)
146 :param metadata: metadata = sqlalchemy.MetaData()
148 return Table("wrregion", metadata,
149 Column("id", types.Integer, primary_key=True),
150 Column("name", types.Unicode(50)),
151 Column("page_id", types.Integer),
152 Column("border", types.LargeBinary) # MultiPolygon(2, 4326)
156 def wrregioncache_table(metadata):
157 """Returns the sqlalchemy Table representing the "wrregioncache" Winterrodeln table in MediaWiki.
158 Current table definition.
159 * version 1.5 (introduction)
160 :param metadata: metadata = sqlalchemy.MetaData()
162 return Table("wrregioncache", metadata,
163 Column("id", types.Integer, primary_key=True),
164 Column("region_id", types.Integer, schema.ForeignKey('wrregin.id')),
165 Column("page_id", types.Integer)
169 def wrintermapssledrun_table(metadata):
170 """Returns the sqlalchemy table representing the "wrintermapssledrun" Winterrodeln table in MediaWiki.
171 Current table definition.
172 * version 1.5 (introduction)
173 :param metadata: metadata = sqlalchemy.MetaData()
175 return Table("wrintermapssledrun", metadata,
176 Column("intermaps_sledrun_id", intermaps_sledrun_id_type, primary_key=True),
177 Column("intermaps_sledrun_name", types.Unicode(255)),
178 Column("intermaps_region_id", types.Integer),
179 Column("intermaps_region_name", types.Unicode(255)),
180 Column("intermaps_country", types.Unicode(10)),
181 Column("wr_page_id", types.Integer, schema.ForeignKey("page.page_id")),
182 Column("wr_page_title", types.Unicode(255)),
183 Column("show_status", types.Boolean, nullable=False)
187 def wrintermapsreport_table(metadata):
188 """Returns the sqlalchemy table representing the "wrintermapsreport" Winterrodeln table in MediaWiki.
189 Current table definition.
190 * version 1.5 (introduction)
191 :param metadata: metadata = sqlalchemy.MetaData()
193 return Table("wrintermapsreport", metadata,
194 Column("intermaps_sledrun_id", intermaps_sledrun_id_type, primary_key=True),
195 Column("status", intermaps_sledrun_status_type, nullable=False),
196 Column("last_update", types.DateTime, nullable=False),
197 Column("last_check", types.DateTime, nullable=False),
198 Column("utc_offset", types.Integer, nullable=False)
202 def wrintermapsreporthistory_table(metadata):
203 """Returns the sqlalchemy table representing the "wrintermapsreporthistory" Winterrodeln table in MediaWiki.
204 Current table definition.
205 * version 1.5 (introduction)
206 :param metadata: metadata = sqlalchemy.MetaData()
208 return Table("wrintermapsreporthistory", metadata,
209 Column("id", types.Integer, primary_key=True),
210 Column("intermaps_sledrun_id", intermaps_sledrun_id_type, nullable=False),
211 Column("status", intermaps_sledrun_status_type, nullable=False),
212 Column("last_update", types.DateTime, nullable=False),
213 Column("utc_offset", types.Integer, nullable=False)