The parse_googlemap function now uses the new XML tag parsing function.
[philipp/winterrodeln/wrpylib.git] / wrpylib / wrmwdb.py
1 #!/usr/bin/python2.7
2 # -*- coding: iso-8859-15 -*-
3 # $Id$
4 # $HeadURL$
5 """This module contains code to make tha access of winterrodeln
6 tables in MediaWiki easy. The module uses sqlalchemy to access the database.
7 """
8 from sqlalchemy import Table, Column, types, schema
9
10
11 def wrreport_table(metadata):
12     """Returns the sqlalchemy Table representing the "wrreport" Winterrodeln table in MediaWiki.
13     Current table definition.
14     * version 1.2
15     * version 1.3 (no changes)
16     * version 1.4 (no changes)
17     * version 1.5 added time_report
18     :param metadata: metadata = sqlalchemy.MetaData()
19     """
20     return Table("wrreport", metadata,
21     Column("id", types.Integer, primary_key=True),
22     Column("page_id", types.Integer, schema.ForeignKey('wrsledruncache.page_id')),
23     Column("page_title", types.Unicode(255), nullable=False),
24     Column("date_report", types.Date),
25     Column("time_report", types.Time),
26     Column("date_entry", types.DateTime, nullable=False),
27     Column("date_invalid", types.DateTime),
28     Column("condition", types.Integer),
29     Column("description", types.Unicode),
30     Column("author_name", types.Unicode(30)),
31     Column("author_ip", types.Unicode(15)),
32     Column("author_userid", types.Integer),
33     Column("author_username", types.Unicode(30)),
34     Column("delete_date", types.DateTime),
35     Column("delete_person_name", types.Unicode(30)),
36     Column("delete_person_ip", types.Unicode(15)),
37     Column("delete_person_userid", types.Integer),
38     Column("delete_person_username", types.Unicode(30)),
39     Column("delete_reason_public", types.Unicode),
40     Column("delete_invisible", types.Boolean),
41     )
42
43
44 def wrsledruncache_table(metadata):
45     """Returns the sqlalchemy Table representing the "wrsledruncache" Winterrodeln table in MediaWiki.
46     Current table definition
47     * version 1.4 (renamed table and added column walkup_possible)
48     :param metadata: metadata = sqlalchemy.MetaData()
49     """
50     return Table("wrsledruncache", metadata,
51     Column("page_id", types.Integer, schema.ForeignKey('wrreportcache.page_id'), primary_key=True),
52     Column("page_title", types.Unicode(255)),
53     Column("position_latitude", types.Float),
54     Column("position_longitude", types.Float),
55     Column("top_latitude", types.Float),
56     Column("top_longitude", types.Float),
57     Column("top_elevation", types.Integer),
58     Column("bottom_latitude", types.Float),
59     Column("bottom_longitude", types.Float),
60     Column("bottom_elevation", types.Integer),
61     Column("length", types.Integer),
62     Column("difficulty", types.Integer),
63     Column("avalanches", types.Integer),
64     Column("operator", types.Unicode(255)),
65     Column("public_transport", types.Integer),
66     Column("walkup_possible", types.Boolean),
67     Column("walkup_time", types.Integer),
68     Column("walkup_separate", types.Float),
69     Column("walkup_separate_comment", types.Unicode(255)),
70     Column("lift", types.Boolean),
71     Column("lift_details", types.Unicode(255)),
72     Column("night_light", types.Float),
73     Column("night_light_comment", types.Unicode(255)),
74     Column("night_light_days", types.Integer),
75     Column("night_light_days_comment", types.Unicode(255)),
76     Column("sled_rental", types.Boolean),
77     Column("sled_rental_comment", types.Unicode(255)),
78     Column("cachet", types.Unicode(255)),
79     Column("information_web", types.Unicode(255)),
80     Column("information_phone", types.Unicode(255)),
81     Column("image", types.Unicode(255)),
82     Column("show_in_overview", types.Boolean),
83     Column("forum_id", types.Integer),
84     Column("under_construction", types.Boolean),
85     )
86
87
88 def wrinncache_table(metadata):
89     """Returns the sqlalchemy Table representing the "wrinncache" Winterrodeln table in MediaWiki.
90     Current table definition
91     * version 1.3 (changes made from version 1.2)
92     * version 1.4 (no changes)
93     :param metadata: metadata = sqlalchemy.MetaData()
94     """
95     return Table("wrinncache", metadata,
96     Column("page_id", types.Integer, primary_key=True),
97     Column("page_title", types.Unicode(255)),
98     Column("position_latitude", types.Float),
99     Column("position_longitude", types.Float),
100     Column("position_elevation", types.Integer),
101     Column("operator", types.Unicode(255)),
102     Column("seats", types.Integer),
103     Column("overnight", types.Boolean),
104     Column("overnight_comment", types.Unicode(255)),
105     Column("smoker_area", types.Boolean),
106     Column("nonsmoker_area", types.Boolean),
107     Column("sled_rental", types.Boolean),
108     Column("sled_rental_comment", types.Unicode(255)),
109     Column("mobile_provider", types.Unicode),
110     Column("homepage", types.Unicode(255)),
111     Column("email_list", types.Unicode),
112     Column("phone_list", types.Unicode),
113     Column("image", types.Unicode(255)),
114     Column("sledding_list", types.Unicode),
115     Column("under_construction", types.Boolean),
116     )
117
118
119 def wrreportcache_table(metadata):
120     """Returns the sqlalchemy Table representing the "wrreportcache" Winterrodeln table in MediaWiki.
121     Current table definition.
122     * version 1.5 (introduction)
123     :param metadata: metadata = sqlalchemy.MetaData()
124     """
125     return Table("wrreportcache", metadata,
126     Column("page_id", types.Integer, primary_key=True),
127     Column("page_title", types.Unicode(255), nullable=False),
128     Column("report_id", types.Integer, schema.ForeignKey('wrreport.id')),
129     Column("date_report", types.Date),
130     Column("condition", types.Integer),
131     Column("description", types.Unicode),
132     Column("author_name", types.Unicode(30)),
133     Column("author_username", types.Unicode(30))
134     )
135
136