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