2 # -*- coding: iso-8859-15 -*-
5 """This module contains code to make tha access of winterrodeln
6 tables in MediaWiki easy. The module uses sqlalchemy to access the database.
8 from sqlalchemy import Table, Column, types, schema
9 from geoalchemy import GeometryExtensionColumn, MultiPolygon
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("position_latitude", types.Float),
55 Column("position_longitude", types.Float),
56 Column("top_latitude", types.Float),
57 Column("top_longitude", types.Float),
58 Column("top_elevation", types.Integer),
59 Column("bottom_latitude", types.Float),
60 Column("bottom_longitude", types.Float),
61 Column("bottom_elevation", types.Integer),
62 Column("length", types.Integer),
63 Column("difficulty", types.Integer),
64 Column("avalanches", types.Integer),
65 Column("operator", types.Unicode(255)),
66 Column("public_transport", types.Integer),
67 Column("walkup_possible", types.Boolean),
68 Column("walkup_time", types.Integer),
69 Column("walkup_separate", types.Float),
70 Column("walkup_separate_comment", types.Unicode(255)),
71 Column("lift", types.Boolean),
72 Column("lift_details", types.Unicode(255)),
73 Column("night_light", types.Float),
74 Column("night_light_comment", types.Unicode(255)),
75 Column("night_light_days", types.Integer),
76 Column("night_light_days_comment", types.Unicode(255)),
77 Column("sled_rental", types.Boolean),
78 Column("sled_rental_comment", types.Unicode(255)),
79 Column("cachet", types.Unicode(255)),
80 Column("information_web", types.Unicode(255)),
81 Column("information_phone", types.Unicode(255)),
82 Column("image", types.Unicode(255)),
83 Column("show_in_overview", types.Boolean),
84 Column("forum_id", types.Integer),
85 Column("under_construction", types.Boolean),
89 def wrinncache_table(metadata):
90 """Returns the sqlalchemy Table representing the "wrinncache" Winterrodeln table in MediaWiki.
91 Current table definition
92 * version 1.3 (changes made from version 1.2)
93 * version 1.4 (no changes)
94 :param metadata: metadata = sqlalchemy.MetaData()
96 return Table("wrinncache", metadata,
97 Column("page_id", types.Integer, primary_key=True),
98 Column("page_title", types.Unicode(255)),
99 Column("position_latitude", types.Float),
100 Column("position_longitude", types.Float),
101 Column("position_elevation", types.Integer),
102 Column("operator", types.Unicode(255)),
103 Column("seats", types.Integer),
104 Column("overnight", types.Boolean),
105 Column("overnight_comment", types.Unicode(255)),
106 Column("smoker_area", types.Boolean),
107 Column("nonsmoker_area", types.Boolean),
108 Column("sled_rental", types.Boolean),
109 Column("sled_rental_comment", types.Unicode(255)),
110 Column("mobile_provider", types.Unicode),
111 Column("homepage", types.Unicode(255)),
112 Column("email_list", types.Unicode),
113 Column("phone_list", types.Unicode),
114 Column("image", types.Unicode(255)),
115 Column("sledding_list", types.Unicode),
116 Column("under_construction", types.Boolean),
120 def wrreportcache_table(metadata):
121 """Returns the sqlalchemy Table representing the "wrreportcache" Winterrodeln table in MediaWiki.
122 Current table definition.
123 * version 1.5 (introduction)
124 :param metadata: metadata = sqlalchemy.MetaData()
126 return Table("wrreportcache", metadata,
127 Column("page_id", types.Integer, primary_key=True),
128 Column("page_title", types.Unicode(255), nullable=False),
129 Column("report_id", types.Integer, schema.ForeignKey('wrreport.id')),
130 Column("date_report", types.Date),
131 Column("condition", types.Integer),
132 Column("description", types.Unicode),
133 Column("author_name", types.Unicode(30)),
134 Column("author_username", types.Unicode(30))
138 def wrregion_table(metadata):
139 """Returns the sqlalchemy Table representing the "wrregion" Winterrodeln table in MediaWiki.
140 Current table definition.
141 * version 1.5 (introduction)
142 :param metadata: metadata = sqlalchemy.MetaData()
144 return Table("wrregion", metadata,
145 Column("id", types.Integer, primary_key=True),
146 Column("name", types.Unicode(50)),
147 Column("page_id", types.Integer),
148 GeometryExtensionColumn("border", MultiPolygon(2, 4326))
152 def wrregioncache_table(metadata):
153 """Returns the sqlalchemy Table representing the "wrregioncache" Winterrodeln table in MediaWiki.
154 Current table definition.
155 * version 1.5 (introduction)
156 :param metadata: metadata = sqlalchemy.MetaData()
158 return Table("wrregioncache", metadata,
159 Column("id", types.Integer, primary_key=True),
160 Column("region_id", types.Integer, schema.ForeignKey('wrregin.id')),
161 Column("page_id", types.Integer)