]> ToastFreeware Gitweb - philipp/winterrodeln/wradmin.git/blob - wradmin/wradmin/model/__init__.py
936dbc9d2ca547ec3d702ebb55c5196f7e8a85ae
[philipp/winterrodeln/wradmin.git] / wradmin / wradmin / model / __init__.py
1 "Model of wradmin"
2 import sqlalchemy as sa
3 from sqlalchemy import orm, schema, types
4 from wradmin.model import meta
5 import datetime
6
7 def init_model(engine):
8     """Call me before using any of the tables or classes in the model"""
9     meta.Session.configure(bind=engine)
10     meta.engine = engine
11
12
13 # Current table definition
14 # - version 1.2
15 # - version 1.3 (no changes)
16 # - version 1.4 (no changes)
17 wrreport_table = sa.Table("wrreport", meta.metadata,
18     sa.Column("id", types.Integer, primary_key=True),
19     sa.Column("page_id", types.Integer, schema.ForeignKey('wrsleddingcache.page_id')),
20     sa.Column("page_title", types.Unicode(255), nullable=False),
21     sa.Column("date_report", types.Date),
22     sa.Column("date_entry", types.DateTime, nullable=False),
23     sa.Column("date_invalid", types.DateTime),
24     sa.Column("condition", types.Integer),
25     sa.Column("description", types.Unicode),
26     sa.Column("author_name", types.Unicode(30)),
27     sa.Column("author_ip", types.Unicode(15)),
28     sa.Column("author_userid", types.Integer),
29     sa.Column("author_username", types.Unicode(30)),
30     sa.Column("delete_date", types.DateTime),
31     sa.Column("delete_person_name", types.Unicode(30)),
32     sa.Column("delete_person_ip", types.Unicode(15)),
33     sa.Column("delete_person_userid", types.Integer),
34     sa.Column("delete_person_username", types.Unicode(30)),
35     sa.Column("delete_reason_public", types.Unicode),
36     )
37
38
39 # Old table definition
40 # - version 1.2
41 wrsleddingcache_table1_2 =  sa.Table("wrsleddingcache1_2", meta.metadata,
42     sa.Column("page_id", types.Integer, primary_key=True),
43     sa.Column("page_title", types.Unicode(255)),
44     sa.Column("length", types.Integer),
45     sa.Column("walktime", types.Integer),
46     sa.Column("height_top", types.Integer),
47     sa.Column("height_bottom", types.Integer),
48     sa.Column("walkup_separate", types.Boolean),
49     sa.Column("lift", types.Boolean),
50     sa.Column("night_light", types.Boolean),
51     sa.Column("sledge_rental", types.Boolean),
52     sa.Column("public_transport", types.Boolean),
53     sa.Column("image", types.Unicode(255)),
54     sa.Column("position_latitude", types.Float),
55     sa.Column("position_longitude", types.Float),
56     sa.Column("information", types.Unicode(255)),
57     sa.Column("forum_id", types.Integer),
58     sa.Column("under_construction", types.Boolean),
59     sa.Column("show_in_overview", types.Boolean),
60     )
61
62
63 # Old table definition
64 # - version 1.3 (changes made from version 1.2)
65 wrsleddingcache_table1_3 =  sa.Table("wrsleddingcache1_3", meta.metadata,
66     sa.Column("page_id", types.Integer, primary_key=True),
67     sa.Column("page_title", types.Unicode(255)),
68     sa.Column("position_latitude", types.Float),
69     sa.Column("position_longitude", types.Float),
70     sa.Column("top_latitude", types.Float),
71     sa.Column("top_longitude", types.Float),
72     sa.Column("top_elevation", types.Integer),
73     sa.Column("bottom_latitude", types.Float),
74     sa.Column("bottom_longitude", types.Float),
75     sa.Column("bottom_elevation", types.Integer),
76     sa.Column("length", types.Integer),
77     sa.Column("difficulty", types.Integer),
78     sa.Column("avalanches", types.Integer),
79     sa.Column("operator", types.Unicode(255)),
80     sa.Column("public_transport", types.Integer),
81     sa.Column("walkup_time", types.Integer),
82     sa.Column("walkup_separate", types.Float),
83     sa.Column("walkup_separate_comment", types.Unicode(255)),
84     sa.Column("lift", types.Boolean),
85     sa.Column("lift_details", types.Unicode(255)),
86     sa.Column("night_light", types.Float),
87     sa.Column("night_light_comment", types.Unicode(255)),
88     sa.Column("night_light_days", types.Integer),
89     sa.Column("night_light_days_comment", types.Unicode(255)),
90     sa.Column("sled_rental", types.Boolean),
91     sa.Column("sled_rental_comment", types.Unicode(255)),
92     sa.Column("cachet", types.Unicode(255)),
93     sa.Column("information_web", types.Unicode(255)),
94     sa.Column("information_phone", types.Unicode(255)),
95     sa.Column("image", types.Unicode(255)),
96     sa.Column("show_in_overview", types.Boolean),
97     sa.Column("forum_id", types.Integer),
98     sa.Column("under_construction", types.Boolean),
99     )
100
101
102 # Current table definition
103 # - version 1.4 (renamed table and added column walkup_possible)
104 wrsledruncache_table =  sa.Table("wrsledruncache", meta.metadata,
105     sa.Column("page_id", types.Integer, primary_key=True),
106     sa.Column("page_title", types.Unicode(255)),
107     sa.Column("position_latitude", types.Float),
108     sa.Column("position_longitude", types.Float),
109     sa.Column("top_latitude", types.Float),
110     sa.Column("top_longitude", types.Float),
111     sa.Column("top_elevation", types.Integer),
112     sa.Column("bottom_latitude", types.Float),
113     sa.Column("bottom_longitude", types.Float),
114     sa.Column("bottom_elevation", types.Integer),
115     sa.Column("length", types.Integer),
116     sa.Column("difficulty", types.Integer),
117     sa.Column("avalanches", types.Integer),
118     sa.Column("operator", types.Unicode(255)),
119     sa.Column("public_transport", types.Integer),
120     sa.Column("walkup_possible", types.Boolean),
121     sa.Column("walkup_time", types.Integer),
122     sa.Column("walkup_separate", types.Float),
123     sa.Column("walkup_separate_comment", types.Unicode(255)),
124     sa.Column("lift", types.Boolean),
125     sa.Column("lift_details", types.Unicode(255)),
126     sa.Column("night_light", types.Float),
127     sa.Column("night_light_comment", types.Unicode(255)),
128     sa.Column("night_light_days", types.Integer),
129     sa.Column("night_light_days_comment", types.Unicode(255)),
130     sa.Column("sled_rental", types.Boolean),
131     sa.Column("sled_rental_comment", types.Unicode(255)),
132     sa.Column("cachet", types.Unicode(255)),
133     sa.Column("information_web", types.Unicode(255)),
134     sa.Column("information_phone", types.Unicode(255)),
135     sa.Column("image", types.Unicode(255)),
136     sa.Column("show_in_overview", types.Boolean),
137     sa.Column("forum_id", types.Integer),
138     sa.Column("under_construction", types.Boolean),
139     )
140
141
142 # Old table definition
143 # - version 1.2
144 wrinncache_table1_2 =  sa.Table("wrinncache1_2", meta.metadata,
145     sa.Column("page_id", types.Integer, primary_key=True),
146     sa.Column("page_title", types.Unicode(255)),
147     sa.Column("height", types.Integer),
148     sa.Column("phone", types.Unicode(30)),
149     sa.Column("mobile_phone", types.Unicode(30)),
150     sa.Column("email", types.Unicode(255)),
151     sa.Column("homepage", types.Unicode(255)),
152     sa.Column("smoker_area", types.Boolean),
153     sa.Column("nonsmoker_area", types.Boolean),
154     sa.Column("image", types.Unicode(255)),
155     sa.Column("position_latitude", types.Float),
156     sa.Column("position_longitude", types.Float),
157     sa.Column("under_construction", types.Boolean),
158     )
159
160
161 # Current table definition
162 # - version 1.3 (changes made from version 1.2)
163 # - version 1.4 (no changes)
164 wrinncache_table =  sa.Table("wrinncache", meta.metadata,
165     sa.Column("page_id", types.Integer, primary_key=True),
166     sa.Column("page_title", types.Unicode(255)),
167     sa.Column("position_latitude", types.Float),
168     sa.Column("position_longitude", types.Float),
169     sa.Column("position_elevation", types.Integer),
170     sa.Column("seats", types.Integer),
171     sa.Column("overnight", types.Boolean),
172     sa.Column("overnight_comment", types.Unicode(255)),
173     sa.Column("smoker_area", types.Boolean),
174     sa.Column("nonsmoker_area", types.Boolean),
175     sa.Column("sled_rental", types.Boolean),
176     sa.Column("sled_rental_comment", types.Unicode(255)),
177     sa.Column("mobile_provider", types.Unicode),
178     sa.Column("homepage", types.Unicode(255)),
179     sa.Column("email_list", types.Unicode),
180     sa.Column("phone_list", types.Unicode),
181     sa.Column("image", types.Unicode(255)),
182     sa.Column("sledding_list", types.Unicode),
183     sa.Column("under_construction", types.Boolean),
184     )
185
186
187 page_table = sa.Table("page", meta.metadata,
188     sa.Column("page_id", types.Integer, primary_key=True),
189     sa.Column("page_namespace", types.Integer, nullable=False),
190     sa.Column("page_title", types.Unicode(255), nullable=False),
191     sa.Column("page_restrictions", types.Unicode, nullable=False),
192     sa.Column("page_counter", types.Integer, nullable=False),
193     sa.Column("page_is_redirect", types.Integer, nullable=False),
194     sa.Column("page_is_new", types.Integer, nullable=False),
195     sa.Column("page_random", types.Float, nullable=False),
196     sa.Column("page_touched", types.Unicode(14), nullable=False),
197     sa.Column("page_latest", types.Integer, nullable=False),
198     sa.Column("page_len", types.Integer, nullable=False),
199     )
200
201
202 revision_table = sa.Table("revision", meta.metadata,
203     sa.Column("rev_id", types.Integer, nullable=False, primary_key=True),
204     sa.Column("rev_page", types.Integer, nullable=False, primary_key=True),
205     sa.Column("rev_text_id", types.Integer, nullable=False),
206     sa.Column("rev_comment", types.Unicode),
207     sa.Column("rev_user", types.Integer, nullable=False),
208     sa.Column("rev_user_text", types.Unicode(255), nullable=False),
209     sa.Column("rev_timestamp", types.Unicode(14), nullable=False),
210     sa.Column("rev_minor_edit", types.Integer, nullable=False),
211     sa.Column("rev_deleted", types.Integer, nullable=False),
212     sa.Column("rev_len", types.Integer, nullable=False),
213     sa.Column("rev_parent_id", types.Integer, nullable=False),
214     )
215
216
217 text_table = sa.Table("text", meta.metadata,
218     sa.Column("old_id", types.Integer, primary_key=True),
219     sa.Column("old_text", types.Unicode),
220     sa.Column("old_flags", types.Unicode),
221     )
222
223
224 categorylinks_table = sa.Table("categorylinks", meta.metadata,
225     sa.Column("cl_from", types.Integer, nullable=False, primary_key=True),
226     sa.Column("cl_to", types.Unicode(255), nullable=False, primary_key=True),
227     sa.Column("cl_sortkey", types.Unicode, nullable=False),
228     sa.Column("cl_timestamp", types.DateTime, nullable=False),
229     )
230
231
232 class WrReport(object):
233     pass
234
235
236 # Old version (not mapped)
237 class WrSleddingCache1_2(object):
238     pass
239
240
241 class WrSledrunCache(object):
242     pass
243
244
245 # Old version (not mapped)
246 class WrInnCache1_2(object):
247     pass
248
249
250 class WrInnCache(object):
251     pass
252
253
254 # Page (not mapped)
255 class Page(object):
256     pass
257
258
259 orm.mapper(WrReport, wrreport_table)
260 # We could add a relation but we don't need it yet:
261 # orm.mapper(WrSledrunCache, wrsledruncache_table, properties = {'reports': orm.relation(WrReport, backref='sledding')})
262 orm.mapper(WrSledrunCache, wrsledruncache_table)
263 orm.mapper(WrInnCache, wrinncache_table)
264