]> ToastFreeware Gitweb - philipp/winterrodeln/wrpylib.git/blobdiff - wrpylib/wrmwdb.py
Nähere Details zu Rodelverleihs.
[philipp/winterrodeln/wrpylib.git] / wrpylib / wrmwdb.py
index 198c3901c3e62a37e1c3e0baaed0c5bf5f752148..e0d8dd185e7ad658a1e77dd4b06f804ac49eea1b 100644 (file)
@@ -1,11 +1,12 @@
-#!/usr/bin/python2.6
-# -*- coding: iso-8859-15 -*-
-# $Id$
-# $HeadURL$
 """This module contains code to make tha access of winterrodeln
 tables in MediaWiki easy. The module uses sqlalchemy to access the database.
 """
 from sqlalchemy import Table, Column, types, schema
+from sqlalchemy.dialects.mysql import ENUM
+
+
+intermaps_sledrun_id_type = types.Unicode(50)
+intermaps_sledrun_status_type = ENUM('open', 'closed', 'in_preparation', 'unknown')
 
 
 def wrreport_table(metadata):
@@ -17,70 +18,74 @@ def wrreport_table(metadata):
     * version 1.5 added time_report
     :param metadata: metadata = sqlalchemy.MetaData()
     """
-    return Table("wrreport", metadata,
-    Column("id", types.Integer, primary_key=True),
-    Column("page_id", types.Integer, schema.ForeignKey('wrsledruncache.page_id')),
-    Column("page_title", types.Unicode(255), nullable=False),
-    Column("date_report", types.Date),
-    Column("time_report", types.Time),
-    Column("date_entry", types.DateTime, nullable=False),
-    Column("date_invalid", types.DateTime),
-    Column("condition", types.Integer),
-    Column("description", types.Unicode),
-    Column("author_name", types.Unicode(30)),
-    Column("author_ip", types.Unicode(15)),
-    Column("author_userid", types.Integer),
-    Column("author_username", types.Unicode(30)),
-    Column("delete_date", types.DateTime),
-    Column("delete_person_name", types.Unicode(30)),
-    Column("delete_person_ip", types.Unicode(15)),
-    Column("delete_person_userid", types.Integer),
-    Column("delete_person_username", types.Unicode(30)),
-    Column("delete_reason_public", types.Unicode),
+    return Table(
+        "wrreport", metadata,
+        Column("id", types.Integer, primary_key=True),
+        Column("page_id", types.Integer, schema.ForeignKey('wrsledruncache.page_id')),
+        Column("page_title", types.Unicode(255), nullable=False),
+        Column("date_report", types.Date),
+        Column("time_report", types.Time),
+        Column("date_entry", types.DateTime, nullable=False),
+        Column("date_invalid", types.DateTime),
+        Column("condition", types.Integer),
+        Column("description", types.Unicode),
+        Column("author_name", types.Unicode(30)),
+        Column("author_ip", types.Unicode(15)),
+        Column("author_userid", types.Integer),
+        Column("author_username", types.Unicode(30)),
+        Column("delete_date", types.DateTime),
+        Column("delete_person_name", types.Unicode(30)),
+        Column("delete_person_ip", types.Unicode(15)),
+        Column("delete_person_userid", types.Integer),
+        Column("delete_person_username", types.Unicode(30)),
+        Column("delete_reason_public", types.Unicode),
+        Column("delete_invisible", types.Boolean),
     )
 
 
-def wrsledruncache_table(metadata):
+def wrsledruncache_table(metadata) -> Table:
     """Returns the sqlalchemy Table representing the "wrsledruncache" Winterrodeln table in MediaWiki.
     Current table definition
     * version 1.4 (renamed table and added column walkup_possible)
     :param metadata: metadata = sqlalchemy.MetaData()
     """
-    return Table("wrsledruncache", metadata,
-    Column("page_id", types.Integer, primary_key=True),
-    Column("page_title", types.Unicode(255)),
-    Column("position_latitude", types.Float),
-    Column("position_longitude", types.Float),
-    Column("top_latitude", types.Float),
-    Column("top_longitude", types.Float),
-    Column("top_elevation", types.Integer),
-    Column("bottom_latitude", types.Float),
-    Column("bottom_longitude", types.Float),
-    Column("bottom_elevation", types.Integer),
-    Column("length", types.Integer),
-    Column("difficulty", types.Integer),
-    Column("avalanches", types.Integer),
-    Column("operator", types.Unicode(255)),
-    Column("public_transport", types.Integer),
-    Column("walkup_possible", types.Boolean),
-    Column("walkup_time", types.Integer),
-    Column("walkup_separate", types.Float),
-    Column("walkup_separate_comment", types.Unicode(255)),
-    Column("lift", types.Boolean),
-    Column("lift_details", types.Unicode(255)),
-    Column("night_light", types.Float),
-    Column("night_light_comment", types.Unicode(255)),
-    Column("night_light_days", types.Integer),
-    Column("night_light_days_comment", types.Unicode(255)),
-    Column("sled_rental", types.Boolean),
-    Column("sled_rental_comment", types.Unicode(255)),
-    Column("cachet", types.Unicode(255)),
-    Column("information_web", types.Unicode(255)),
-    Column("information_phone", types.Unicode(255)),
-    Column("image", types.Unicode(255)),
-    Column("show_in_overview", types.Boolean),
-    Column("forum_id", types.Integer),
-    Column("under_construction", types.Boolean),
+    return Table(
+        "wrsledruncache", metadata,
+        Column("page_id", types.Integer, schema.ForeignKey('wrreportcache.page_id'), primary_key=True),
+        Column("page_title", types.Unicode(255)),
+        Column("name_url", types.Unicode(255)),
+        Column("position_latitude", types.Float),
+        Column("position_longitude", types.Float),
+        Column("top_latitude", types.Float),
+        Column("top_longitude", types.Float),
+        Column("top_elevation", types.Integer),
+        Column("bottom_latitude", types.Float),
+        Column("bottom_longitude", types.Float),
+        Column("bottom_elevation", types.Integer),
+        Column("length", types.Integer),
+        Column("difficulty", types.Integer),
+        Column("avalanches", types.Integer),
+        Column("operator", types.Unicode(255)),
+        Column("public_transport", types.Integer),
+        Column("walkup_possible", types.Boolean),
+        Column("walkup_time", types.Integer),
+        Column("walkup_separate", types.Float),
+        Column("walkup_separate_comment", types.Unicode(255)),
+        Column("lift", types.Boolean),
+        Column("lift_details", types.Unicode(255)),
+        Column("night_light", types.Float),
+        Column("night_light_comment", types.Unicode(255)),
+        Column("night_light_days", types.Integer),
+        Column("night_light_days_comment", types.Unicode(255)),
+        Column("sled_rental", types.Boolean),
+        Column("sled_rental_comment", types.Unicode(255)),
+        Column("cachet", types.Unicode(255)),
+        Column("information_web", types.Unicode(255)),
+        Column("information_phone", types.Unicode(255)),
+        Column("image", types.Unicode(255)),
+        Column("show_in_overview", types.Boolean),
+        Column("forum_id", types.Integer),
+        Column("under_construction", types.Boolean),
     )
 
 
@@ -91,27 +96,28 @@ def wrinncache_table(metadata):
     * version 1.4 (no changes)
     :param metadata: metadata = sqlalchemy.MetaData()
     """
-    return Table("wrinncache", metadata,
-    Column("page_id", types.Integer, primary_key=True),
-    Column("page_title", types.Unicode(255)),
-    Column("position_latitude", types.Float),
-    Column("position_longitude", types.Float),
-    Column("position_elevation", types.Integer),
-    Column("operator", types.Unicode(255)),
-    Column("seats", types.Integer),
-    Column("overnight", types.Boolean),
-    Column("overnight_comment", types.Unicode(255)),
-    Column("smoker_area", types.Boolean),
-    Column("nonsmoker_area", types.Boolean),
-    Column("sled_rental", types.Boolean),
-    Column("sled_rental_comment", types.Unicode(255)),
-    Column("mobile_provider", types.Unicode),
-    Column("homepage", types.Unicode(255)),
-    Column("email_list", types.Unicode),
-    Column("phone_list", types.Unicode),
-    Column("image", types.Unicode(255)),
-    Column("sledding_list", types.Unicode),
-    Column("under_construction", types.Boolean),
+    return Table(
+        "wrinncache", metadata,
+        Column("page_id", types.Integer, primary_key=True),
+        Column("page_title", types.Unicode(255)),
+        Column("position_latitude", types.Float),
+        Column("position_longitude", types.Float),
+        Column("position_elevation", types.Integer),
+        Column("operator", types.Unicode(255)),
+        Column("seats", types.Integer),
+        Column("overnight", types.Boolean),
+        Column("overnight_comment", types.Unicode(255)),
+        Column("smoker_area", types.Boolean),
+        Column("nonsmoker_area", types.Boolean),
+        Column("sled_rental", types.Boolean),
+        Column("sled_rental_comment", types.Unicode(255)),
+        Column("mobile_provider", types.Unicode),
+        Column("homepage", types.Unicode(255)),
+        Column("email_list", types.Unicode),
+        Column("phone_list", types.Unicode),
+        Column("image", types.Unicode(255)),
+        Column("sledding_list", types.Unicode),
+        Column("under_construction", types.Boolean),
     )
 
 
@@ -121,15 +127,95 @@ def wrreportcache_table(metadata):
     * version 1.5 (introduction)
     :param metadata: metadata = sqlalchemy.MetaData()
     """
-    return Table("wrreportcache", metadata,
-    Column("page_id", types.Integer, primary_key=True),
-    Column("page_title", types.Unicode(255), nullable=False),
-    Column("report_id", types.Integer),
-    Column("date_report", types.Date),
-    Column("condition", types.Integer),
-    Column("description", types.Unicode),
-    Column("author_name", types.Unicode(30)),
-    Column("author_username", types.Unicode(30))
+    return Table(
+        "wrreportcache", metadata,
+        Column("page_id", types.Integer, primary_key=True),
+        Column("page_title", types.Unicode(255), nullable=False),
+        Column("report_id", types.Integer, schema.ForeignKey('wrreport.id')),
+        Column("date_report", types.Date),
+        Column("condition", types.Integer),
+        Column("description", types.Unicode),
+        Column("author_name", types.Unicode(30)),
+        Column("author_username", types.Unicode(30))
+    )
+
+
+def wrregion_table(metadata):
+    """Returns the sqlalchemy Table representing the "wrregion" Winterrodeln table in MediaWiki.
+    Current table definition.
+    * version 1.5 (introduction)
+    :param metadata: metadata = sqlalchemy.MetaData()
+    """
+    return Table(
+        "wrregion", metadata,
+        Column("id", types.Integer, primary_key=True),
+        Column("name", types.Unicode(50)),
+        Column("page_id", types.Integer),
+        Column("border", types.LargeBinary)  # MultiPolygon(2, 4326)
     )
 
 
+def wrregioncache_table(metadata):
+    """Returns the sqlalchemy Table representing the "wrregioncache" Winterrodeln table in MediaWiki.
+    Current table definition.
+    * version 1.5 (introduction)
+    :param metadata: metadata = sqlalchemy.MetaData()
+    """
+    return Table(
+        "wrregioncache", metadata,
+        Column("id", types.Integer, primary_key=True),
+        Column("region_id", types.Integer, schema.ForeignKey('wrregion.id')),
+        Column("page_id", types.Integer)
+    )
+
+
+def wrintermapssledrun_table(metadata):
+    """Returns the sqlalchemy table representing the "wrintermapssledrun" Winterrodeln table in MediaWiki.
+    Current table definition.
+    * version 1.5 (introduction)
+    :param metadata: metadata = sqlalchemy.MetaData()
+    """
+    return Table(
+        "wrintermapssledrun", metadata,
+        Column("intermaps_sledrun_id", intermaps_sledrun_id_type, primary_key=True),
+        Column("intermaps_sledrun_name", types.Unicode(255)),
+        Column("intermaps_region_id", types.Integer),
+        Column("intermaps_region_name", types.Unicode(255)),
+        Column("intermaps_country", types.Unicode(10)),
+        Column("wr_page_id", types.Integer, schema.ForeignKey("page.page_id")),
+        Column("wr_page_title", types.Unicode(255)),
+        Column("show_status", types.Boolean, nullable=False)
+    )
+
+
+def wrintermapsreport_table(metadata):
+    """Returns the sqlalchemy table representing the "wrintermapsreport" Winterrodeln table in MediaWiki.
+    Current table definition.
+    * version 1.5 (introduction)
+    :param metadata: metadata = sqlalchemy.MetaData()
+    """
+    return Table(
+        "wrintermapsreport", metadata,
+        Column("intermaps_sledrun_id", intermaps_sledrun_id_type, primary_key=True),
+        Column("status", intermaps_sledrun_status_type, nullable=False),
+        Column("last_update", types.DateTime, nullable=False),
+        Column("last_check", types.DateTime, nullable=False),
+        Column("utc_offset", types.Integer, nullable=False)
+    )
+
+
+def wrintermapsreporthistory_table(metadata):
+    """Returns the sqlalchemy table representing the "wrintermapsreporthistory" Winterrodeln table in MediaWiki.
+    Current table definition.
+    * version 1.5 (introduction)
+    :param metadata: metadata = sqlalchemy.MetaData()
+    """
+    return Table(
+        "wrintermapsreporthistory", metadata,
+        Column("id", types.Integer, primary_key=True),
+        Column("intermaps_sledrun_id", intermaps_sledrun_id_type, nullable=False),
+        Column("status", intermaps_sledrun_status_type, nullable=False),
+        Column("last_update", types.DateTime, nullable=False),
+        Column("first_check", types.DateTime, nullable=False),
+        Column("utc_offset", types.Integer, nullable=False)
+    )