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