#!/usr/bin/python2.7 # -*- 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 geoalchemy import GeometryExtensionColumn, MultiPolygon def wrreport_table(metadata): """Returns the sqlalchemy Table representing the "wrreport" Winterrodeln table in MediaWiki. Current table definition. * version 1.2 * version 1.3 (no changes) * version 1.4 (no changes) * 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), Column("delete_invisible", types.Boolean), ) def wrsledruncache_table(metadata): """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, schema.ForeignKey('wrreportcache.page_id'), 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), ) def wrinncache_table(metadata): """Returns the sqlalchemy Table representing the "wrinncache" Winterrodeln table in MediaWiki. Current table definition * version 1.3 (changes made from version 1.2) * 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), ) def wrreportcache_table(metadata): """Returns the sqlalchemy Table representing the "wrreportcache" Winterrodeln table in MediaWiki. Current table definition. * 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, 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), GeometryExtensionColumn("border", 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("wrregion_id", types.Integer, schema.ForeignKey('wrregin.id')), Column("page_id", types.Integer) )