]> ToastFreeware Gitweb - philipp/winterrodeln/wradmin.git/commitdiff
Merged vendor branch mediawiki 1.15.3.
authorphilipp <philipp@7aebc617-e5e2-0310-91dc-80fb5f6d2477>
Tue, 13 Apr 2010 20:11:14 +0000 (20:11 +0000)
committerphilipp <philipp@7aebc617-e5e2-0310-91dc-80fb5f6d2477>
Tue, 13 Apr 2010 20:11:14 +0000 (20:11 +0000)
git-svn-id: http://www.winterrodeln.org/svn/servermediawiki/trunk/wradmin@563 7aebc617-e5e2-0310-91dc-80fb5f6d2477

wradmin/setup.py
wradmin/wradmin/controllers/rodelbahn.py
wradmin/wradmin/lib/mediawiki.py
wradmin/wradmin/model/__init__.py
wradmin/wradmin/model/validators.py
wradmin/wradmin/templates/rodelbahn_list.html
wradmin/wradmin/templates/rodelbahn_view.html
wradmin/wradmin/templates/wrgpxtool.html
wradmin/wradmin/tests/test_lib.py
wradmin/wradmin/tests/test_models.py

index 58f8be25f8325008cd1c24f1dc0d8f861428176f..06bdc36d05ce5a01fada50467c5e1841dbdb8d3b 100644 (file)
@@ -19,7 +19,7 @@ setup(
         "AuthKit>=0.4.3,<=0.4.99",
         "SQLAlchemy>=0.5",
         "lxml>=2.2",
         "AuthKit>=0.4.3,<=0.4.99",
         "SQLAlchemy>=0.5",
         "lxml>=2.2",
-        "matplotlib>=0.9",
+        "matplotlib>=0.9",
         "Babel>=0.9"
     ],
     setup_requires=["PasteScript>=1.6.3"],
         "Babel>=0.9"
     ],
     setup_requires=["PasteScript>=1.6.3"],
index 7c3b8063f30852d9c48362f3b17f9508215f0dba..237e6e4f592861ec5382bb084fc8af954997b873 100644 (file)
@@ -20,6 +20,7 @@ class RodelbahnController(BaseController):
     def index(self):
         return render('index.html')
 
     def index(self):
         return render('index.html')
 
+
     def list(self):
         "Lists all sledding routes"
         q = model.meta.Session.query(model.WrSleddingCache)
     def list(self):
         "Lists all sledding routes"
         q = model.meta.Session.query(model.WrSleddingCache)
@@ -41,6 +42,9 @@ class RodelbahnController(BaseController):
     
     def _wikipage_to_wrsleddingcache(self, sledding_wiki):
         "Converts a sledding route wiki page to a sledding route wrsleddingcache database record."
     
     def _wikipage_to_wrsleddingcache(self, sledding_wiki):
         "Converts a sledding route wiki page to a sledding route wrsleddingcache database record."
+        # TODO: Use mediawiki.wikipage_to_wrsleddingcache
+        
+        
         sl = model.WrSleddingCache()
         sl.page_id = sledding_wiki.page_id
         sl.page_title = to_title(sledding_wiki.page_title)
         sl = model.WrSleddingCache()
         sl.page_id = sledding_wiki.page_id
         sl.page_title = to_title(sledding_wiki.page_title)
index 378dd808365903224fd8131d74aad29d46fcb26b..ea05d27ca6468404e4814eb5d822dcb27ef64a49 100644 (file)
@@ -1,14 +1,18 @@
+#!/usr/bin/python2.5
+# -*- coding: iso-8859-15 -*-
+# $Id$
 "MediaWiki communication functions"
 "MediaWiki communication functions"
+import datetime
+import re
 
 from authkit.users import UsersReadOnly, md5
 
 from authkit.users import UsersReadOnly, md5
-import datetime
-import wradmin.model as model
-import wradmin.model.validators
 import formencode, formencode.national
 import formencode, formencode.national
-
 import logging
 log = logging.getLogger(__name__)
 
 import logging
 log = logging.getLogger(__name__)
 
+import wradmin.model as model
+import wradmin.model.validators
+
 
 # Converter functions
 # -------------------
 
 # Converter functions
 # -------------------
@@ -63,10 +67,22 @@ def to_phone_info(value):
     return model.validators.PhoneInfo(messages={'phoneInfo': u"Bitte verwenden Sie ein Format wie '0512/123456 (Schnee Alm)'."}).to_python(value)
 
 
     return model.validators.PhoneInfo(messages={'phoneInfo': u"Bitte verwenden Sie ein Format wie '0512/123456 (Schnee Alm)'."}).to_python(value)
 
 
+def to_valuecommentlist(value):
+    """A value-comment list looks like one of the following lines:
+        value
+        value (optional comment)
+        value1; value2
+        value1; value2 (optional comment)
+        value1 (optional comment1); value2 (optional comment2); value3 (otional comment3)
+        value1 (optional comment1); value2 (optional comment2); value3 (otional comment3)
+    This function returns the value-comment list as list of tuples. If no comment is present, None is specified."""
+    return model.validators.ValueCommentList().to_python(value)
+
+
 def conv(fnct, value, fieldname):
     "Like one of the to_xxx functions (e.g. to_bool), but adds the field name to the error message"
     try: return fnct(value)
 def conv(fnct, value, fieldname):
     "Like one of the to_xxx functions (e.g. to_bool), but adds the field name to the error message"
     try: return fnct(value)
-    except formencode.Invalid, e: raise formencode.Invalid(u"Conversion error in field '%s': %s" % (fieldname, unicode_e(e)), e.value, e.state)
+    except formencode.Invalid, e: raise formencode.Invalid(_(u"Conversion error in field '%s': %s") % (fieldname, unicode_e(e)), e.value, e.state)
 
 
 def unicode_e(exception):
 
 
 def unicode_e(exception):
@@ -77,6 +93,185 @@ def unicode_e(exception):
     return unicode(exception)
 
 
     return unicode(exception)
 
 
+def wikipage_to_wrsleddingcache1_2(wiki_page):
+    """Converts a sledding route wiki page (wradmin.model.page_table) 
+    to a sledding route wrsleddingcache database record (version 1.2) (wradmin.model.wrsleddingcache1_2_table)."""
+    sl = model.WrSleddingCache1_2()
+    sl.page_id = wiki_page.page_id
+    sl.page_title = to_title(wiki_page.page_title)
+    
+    # Match Rodelbahnbox
+    wikitext = wiki_page.old_text
+    regexp = re.compile(u"\{\{(Rodelbahnbox[^\}]*)\}\}", re.DOTALL)
+    match = regexp.search(wikitext)
+    if not match:
+        raise Exception(u"No 'Rodelbahnbox' found")
+    box = match.group(1)
+    
+    # Process Rodelbahnbox
+    for property in box.split('|'):
+        property = property.strip()
+        if property == u'Rodelbahnbox': continue
+        key_value = property.split('=')
+        if len(key_value) != 2:
+            raise Exception(u"Property '%s' has unexpected format" % key_value)
+        key = key_value[0].strip()
+        value = key_value[1].strip()
+        if key == u'Rodelbahnnummer': pass
+        elif key == u'Länge': sl.length = conv(to_unsigned, value, u'Länge')
+        elif key == u'Gehzeit': sl.walktime = conv(to_unsigned, value, u'Gehzeit')
+        elif key == u'Höhe oben': sl.height_top = conv(to_unsigned, value, u'Höhe oben')
+        elif key == u'Höhe unten': sl.height_bottom = conv(to_unsigned, value, u'Höhe unten')
+        elif key == u'Aufstieg getrennt': sl.walkup_separate = conv(to_bool, value, u'Aufstieg getrennt')
+        elif key == u'Lift': sl.lift = conv(to_bool, value, u'Lift')
+        elif key == u'Beleuchtung': sl.night_light = conv(to_bool, value, u'Beleuchtung')
+        elif key == u'Rodelverleih': sl.sledge_rental = conv(to_bool, value, u'Rodelverleih')
+        elif key == u'Öffentliche Anreise': sl.public_transport = conv(to_bool, value, u'Öffentliche Anreise')
+        elif key == u'Bild': sl.image = value
+        elif key == u'Position': (sl.position_latitude, sl.position_longitude) = conv(to_geo, value, u'Position') # '47.583333 N 15.75 E'
+        elif key == u'Auskunft': sl.information = conv(to_phone_info, value, u'Auskunft')
+        elif key == u'In Übersichtskarte': sl.show_in_overview = conv(to_bool, value, u'In Übersichtskarte')
+        elif key == u'Aufnahmedatum': sl.creation_date = conv(to_date, value, u'Aufnahmedatum') # '2006-03-15'
+        elif key == u'Lawinengefahr':
+            if not value in [u'kaum', u'selten', u'gelegentlich', u'häufig']: raise formencode.Invalid(u"No valid value for 'Lawinengefahr': '%s'" % value, value, None)
+        else: raise formencode.Invalid(u"Unbekannte Eigenschaft der Rodelbahnbox: '%s' (mit Wert '%s')" % (key, value), value, None)
+    sl.under_construction = None
+    
+    # Match Forumlink (e.g. {{Forumlink|68}})
+    match = re.search(u"\{\{Forumlink\|(\d+)\}\}", wikitext)
+    if match: sl.forum_id = match.group(1)
+    
+    return sl
+
+
+def wikipage_to_wrsleddingcache(wiki_page):
+    """Converts a sledding route wiki page (wradmin.model.page_table) 
+    to a sledding route wrsleddingcache database record (wradmin.model.wrsleddingcache_table).
+    Raises a RuntimeError if the format is not OK
+    sledding_wiki is a column of tabe "page".
+    Returns the WrSleddingCache class"""
+    sl = model.WrSleddingCache()
+    sl.page_id = wiki_page.page_id
+    sl.page_title = to_title(wiki_page.page_title)
+    errors = [] # List of errors with localized messages
+    
+    # Match Rodelbahnbox
+    wikitext = wiki_page.old_text
+    regexp = re.compile(u"\{\{(Rodelbahnbox[^\}]*)\}\}", re.DOTALL)
+    match = regexp.search(wikitext)
+    if not match:
+        raise RuntimeError(_(u"No 'Rodelbahnbox' found"))
+    box = match.group(1)
+    
+    # Process Rodelbahnbox
+    for property in box.split('|'):
+        property = property.strip()
+        if property == u'Rodelbahnbox': continue
+        key_value = property.split('=')
+        if len(key_value) != 2:
+            raise RuntimeError(_(u"Property '%s' has unexpected format") % key_value)
+        key = key_value[0].strip()
+        value = key_value[1].strip()
+        if key in [u'Rodelbahnnummer', u'Lift']:
+            errors.append(_("Property '%s' is not supported anymore, see %s.") % (key, 'http://www.winterrodeln.org/wiki/Vorlage:Rodelbahnbox'))
+        elif key == u'Position': (sl.position_latitude, sl.position_longitude) = conv(to_geo, value, u'Position') # '47.583333 N 15.75 E'
+        elif key == u'Position oben': (sl.top_latitude, sl.top_longitude) = conv(to_geo, value, u'Position oben') # '47.583333 N 15.75 E'
+        
+
+| Höhe oben            = 1700
+| Position unten       = 
+| Höhe unten           = 1200
+| Länge                = 3500
+| Schwierigkeit        = mittel
+| Lawinen              = kaum
+| Betreiber            = Max Mustermann
+| Öffentliche Anreise  = Mittelmäßig
+| Gehzeit              = 90
+| Aufstieg getrennt    = Ja
+| Aufstiegshilfe       = Gondel (unterer Teil)
+| Beleuchtungsanlage   = Ja
+| Beleuchtungstage     = 3 (Montag, Mittwoch, Freitag)
+| Rodelverleih         = Ja (Talstation Serlesbahnan)
+| Gütesiegel           = Tiroler Naturrodelbahn-Gütesiegel 2009 mittel
+| Webauskunft          = http://www.nösslachhütte.at/page9.php
+| Telefonauskunft      = +43-664-5487520 (Mitterer Alm)
+| Bild                 = Rodelbahn_Mitterer_Alm_04.jpg
+| In Übersichtskarte   = Ja
+| Forumid              = 33
+            
+    sa.Column("top_elevation", types.Integer),
+    sa.Column("bottom_latitude", types.Float),
+    sa.Column("bottom_longitude", types.Float),
+    sa.Column("bottom_elevation", types.Integer),
+    sa.Column("length", types.Integer),
+    sa.Column("difficulty", types.Integer),
+    sa.Column("avalanches", types.Integer),
+    sa.Column("operator", types.Unicode(255)),
+    sa.Column("public_transport", types.Integer),
+    sa.Column("walkup_time", types.Integer),
+    sa.Column("walkup_separate", types.Float),
+    sa.Column("walkup_separate_comment", types.Unicode(255)),
+    sa.Column("lift", types.Boolean),
+    sa.Column("lift_details", types.Unicode(255)),
+    sa.Column("night_light", types.Float),
+    sa.Column("night_light_days", types.Integer),
+    sa.Column("night_light_days_comment", types.Unicode(255)),
+    sa.Column("sled_rental", types.Boolean),
+    sa.Column("cachet", types.Unicode(255)),
+    sa.Column("information_web", types.Unicode(255)),
+    sa.Column("information_phone", types.Unicode(255)),
+    sa.Column("image", types.Unicode(255)),
+    sa.Column("show_in_overview", types.Boolean),
+    sa.Column("forum_id", types.Integer),
+    sa.Column("under_construction", types.Boolean),
+    )
+
+            
+            
+            
+            
+            
+            
+        elif key == u'Bild': sl.image = value
+
+        elif key == u'Länge': sl.length = conv(to_unsigned, value, u'Länge')
+        elif key == u'Gehzeit': sl.walktime = conv(to_unsigned, value, u'Gehzeit')
+        elif key == u'Höhe oben': sl.height_top = conv(to_unsigned, value, u'Höhe oben')
+        elif key == u'Höhe unten': sl.height_bottom = conv(to_unsigned, value, u'Höhe unten')
+        elif key == u'Aufstieg getrennt':
+            tristate = conv(to_tristate, value, u'Aufstieg getrennt')
+            if tristate == (True, False): sl.walkup_separate = 1.0
+            elif tristate == (True,  True): sl.walkup_separate = 0.5
+            elif tristate == (False, True): sl.walkup_separate = 0.0
+        elif key == u'Aufstiegshilfe':
+            valuecommentlist = conv(to_valuecommentlist, value, u'Aufstiegshilfe')
+            lift = len(valuecommentlist) > 0
+            for value, comment in valuecommentlist:
+                if value == u'Nein':
+                    if len(valuecommentlist) != 1: raise formencode.Invalid('"Nein" kann mit keiner anderen Aufstiegshilfe kombiniert werden.', value, None)
+                    lift = False
+                elif not value in [u'Sessellift', u'Gondel', u'Linienbus', u'Taxi', u'Sonstige']:
+                    raise formencode.Invalid(u'"%s" ist keine gültige Aufstiegshilfe.' % value, value, None)
+            sl.lift = lift
+            sl.lift_detail = model.validators.ValueCommentList().from_python(valuecommentlist)
+        elif key == u'Beleuchtung': sl.night_light = conv(to_bool, value, u'Beleuchtung')
+        elif key == u'Rodelverleih': sl.sledge_rental = conv(to_bool, value, u'Rodelverleih')
+        elif key == u'Öffentliche Anreise': sl.public_transport = conv(to_bool, value, u'Öffentliche Anreise')
+        elif key == u'Auskunft': sl.information = conv(to_phone_info, value, u'Auskunft')
+        elif key == u'In Übersichtskarte': sl.show_in_overview = conv(to_bool, value, u'In Übersichtskarte')
+        elif key == u'Aufnahmedatum': sl.creation_date = conv(to_date, value, u'Aufnahmedatum') # '2006-03-15'
+        elif key == u'Lawinengefahr':
+            if not value in [u'kaum', u'selten', u'gelegentlich', u'häufig']: raise formencode.Invalid(u"No valid value for 'Lawinengefahr': '%s'" % value, value, None)
+        else: raise formencode.Invalid(u"Unbekannte Eigenschaft der Rodelbahnbox: '%s' (mit Wert '%s')" % (key, value), value, None)
+    sl.under_construction = None
+    
+    # Match Forumlink (e.g. {{Forumlink|68}})
+    match = re.search(u"\{\{Forumlink\|(\d+)\}\}", wikitext)
+    if match: sl.forum_id = match.group(1)
+    
+    return sl
+
+
 # User management
 # ---------------
 
 # User management
 # ---------------
 
index f1839b0ab095855fbe454679e4d220437f835c09..c5d29b1013b3bba0d422e6688a47daa7787daa01 100644 (file)
@@ -10,6 +10,9 @@ def init_model(engine):
     meta.engine = engine
 
 
     meta.engine = engine
 
 
+# Current table definition
+# - version 1.2
+# - version 1.3 (no changes)
 wrreport_table = sa.Table("wrreport", meta.metadata,
     sa.Column("id", types.Integer, primary_key=True),
     sa.Column("page_id", types.Integer, schema.ForeignKey('wrsleddingcache.page_id')),
 wrreport_table = sa.Table("wrreport", meta.metadata,
     sa.Column("id", types.Integer, primary_key=True),
     sa.Column("page_id", types.Integer, schema.ForeignKey('wrsleddingcache.page_id')),
@@ -32,7 +35,9 @@ wrreport_table = sa.Table("wrreport", meta.metadata,
     )
 
 
     )
 
 
-wrsleddingcache_table =  sa.Table("wrsleddingcache", meta.metadata,
+# Old table definition
+# - version 1.2
+wrsleddingcache1_2_table =  sa.Table("wrsleddingcache1_2", meta.metadata,
     sa.Column("page_id", types.Integer, primary_key=True),
     sa.Column("page_title", types.Unicode(255)),
     sa.Column("length", types.Integer),
     sa.Column("page_id", types.Integer, primary_key=True),
     sa.Column("page_title", types.Unicode(255)),
     sa.Column("length", types.Integer),
@@ -54,6 +59,64 @@ wrsleddingcache_table =  sa.Table("wrsleddingcache", meta.metadata,
     )
 
 
     )
 
 
+# Current table definition
+# - version 1.3 (changes made from version 1.2)
+wrsleddingcache_table =  sa.Table("wrsleddingcache", meta.metadata,
+    sa.Column("page_id", types.Integer, primary_key=True),
+    sa.Column("page_title", types.Unicode(255)),
+    sa.Column("position_latitude", types.Float),
+    sa.Column("position_longitude", types.Float),
+    sa.Column("top_latitude", types.Float),
+    sa.Column("top_longitude", types.Float),
+    sa.Column("top_elevation", types.Integer),
+    sa.Column("bottom_latitude", types.Float),
+    sa.Column("bottom_longitude", types.Float),
+    sa.Column("bottom_elevation", types.Integer),
+    sa.Column("length", types.Integer),
+    sa.Column("difficulty", types.Integer),
+    sa.Column("avalanches", types.Integer),
+    sa.Column("operator", types.Unicode(255)),
+    sa.Column("public_transport", types.Integer),
+    sa.Column("walkup_time", types.Integer),
+    sa.Column("walkup_separate", types.Float),
+    sa.Column("walkup_separate_comment", types.Unicode(255)),
+    sa.Column("lift", types.Boolean),
+    sa.Column("lift_details", types.Unicode(255)),
+    sa.Column("night_light", types.Float),
+    sa.Column("night_light_days", types.Integer),
+    sa.Column("night_light_days_comment", types.Unicode(255)),
+    sa.Column("sled_rental", types.Boolean),
+    sa.Column("cachet", types.Unicode(255)),
+    sa.Column("information_web", types.Unicode(255)),
+    sa.Column("information_phone", types.Unicode(255)),
+    sa.Column("image", types.Unicode(255)),
+    sa.Column("show_in_overview", types.Boolean),
+    sa.Column("forum_id", types.Integer),
+    sa.Column("under_construction", types.Boolean),
+    )
+
+
+# Old table definition
+# - version 1.2
+wrinncache_table1_2 =  sa.Table("wrinncache1_2", meta.metadata,
+    sa.Column("page_id", types.Integer, primary_key=True),
+    sa.Column("page_title", types.Unicode(255)),
+    sa.Column("height", types.Integer),
+    sa.Column("phone", types.Unicode(30)),
+    sa.Column("mobile_phone", types.Unicode(30)),
+    sa.Column("email", types.Unicode(255)),
+    sa.Column("homepage", types.Unicode(255)),
+    sa.Column("smoker_area", types.Boolean),
+    sa.Column("nonsmoker_area", types.Boolean),
+    sa.Column("image", types.Unicode(255)),
+    sa.Column("position_latitude", types.Float),
+    sa.Column("position_longitude", types.Float),
+    sa.Column("under_construction", types.Boolean),
+    )
+
+
+# Current table definition
+# - version 1.3 (changes made from version 1.2)
 wrinncache_table =  sa.Table("wrinncache", meta.metadata,
     sa.Column("page_id", types.Integer, primary_key=True),
     sa.Column("page_title", types.Unicode(255)),
 wrinncache_table =  sa.Table("wrinncache", meta.metadata,
     sa.Column("page_id", types.Integer, primary_key=True),
     sa.Column("page_title", types.Unicode(255)),
@@ -120,14 +183,29 @@ class WrReport(object):
     pass
 
 
     pass
 
 
+# Old version (not mapped)
+class WrSleddingCache1_2(object):
+    pass
+
+
 class WrSleddingCache(object):
     pass
 
 
 class WrSleddingCache(object):
     pass
 
 
+# Old version (not mapped)
+class WrInnCache1_2(object):
+    pass
+
+
 class WrInnCache(object):
     pass
 
 
 class WrInnCache(object):
     pass
 
 
+# Page (not mapped)
+class Page(object):
+    pass
+
+
 orm.mapper(WrReport, wrreport_table)
 # We could add a relation but we don't need it yet:
 # orm.mapper(WrSleddingCache, wrsleddingcache_table, properties = {'reports': orm.relation(WrReport, backref='sledding')})
 orm.mapper(WrReport, wrreport_table)
 # We could add a relation but we don't need it yet:
 # orm.mapper(WrSleddingCache, wrsleddingcache_table, properties = {'reports': orm.relation(WrReport, backref='sledding')})
index 9f555e854481166ede3aec4578630655ce54b212..c1e494089895148ada1b39c29a88fae87e22013d 100644 (file)
@@ -266,3 +266,38 @@ class PhoneInfo(formencode.FancyValidator):
         phone = AustrianPhoneNumber().to_python(phone)
         
         return "%s (%s)" % (phone, info)
         phone = AustrianPhoneNumber().to_python(phone)
         
         return "%s (%s)" % (phone, info)
+
+
+class ValueCommentList(formencode.FancyValidator):
+    """A value-comment list looks like one of the following lines:
+        value
+        value (optional comment)
+        value1; value2
+        value1; value2 (optional comment)
+        value1 (optional comment1); value2 (optional comment2); value3 (otional comment3)
+        value1 (optional comment1); value2 (optional comment2); value3 (otional comment3)
+    This function returns the value-comment list as list of tuples:
+        [(u'value1', u'comment1'), (u'value2', None)]
+    If no comment is present, None is specified."""
+    messages = {'infoFormat': "'%%(value)s' is no valid format, please use a form like 'value1 (optional comment1); value2 (optional comment2)'"}
+    
+    def _to_python(self, value, state):
+        self.assert_string(value, state)
+        value_options = [s.strip() for s in value.split(';')]
+        result = []
+        for value_option in value_options:
+            left = value_option.find('(')
+            right = value_option.rfind(')')
+            if left < 0 and right < 0:
+                result.append((value_option, None))
+            elif left >= 0 and right >= 0 and left < right:
+                result.append((value_option[:left].strip(), value_option[left+1:right].strip()))
+            else: raise formencode.Invalid(self.message('infoFormat', state) % {'value': value}, value, state)
+        return result
+
+    def _from_python(self, value, state):
+        result = []
+        for v, c in value:
+            if c is None: result.append(v)
+            else: result.append('%s (%s)' % (v, c))
+        return "; ".join(result)
index b9ffe04a97a1f44e1eaefa9dfc130dc5598ce89e..eb77fe898e6b1499d7e88ad9d03ee51c23c566ab 100644 (file)
@@ -50,7 +50,7 @@
         <td>${h.bool(s.walkup_separate)}</td>
         <td>${h.bool(s.lift)}</td>
         <td>${h.bool(s.night_light)}</td>
         <td>${h.bool(s.walkup_separate)}</td>
         <td>${h.bool(s.lift)}</td>
         <td>${h.bool(s.night_light)}</td>
-        <td>${h.bool(s.sledge_rental)}</td>
+        <td>${h.bool(s.sled_rental)}</td>
         <td>${h.bool(s.public_transport)}</td>
         <td><small>${s.image}</small></td>
         <td>${s.position_latitude}</td>
         <td>${h.bool(s.public_transport)}</td>
         <td><small>${s.image}</small></td>
         <td>${s.position_latitude}</td>
index 10fa68579afa9602824f6c2ee130ad973e99a66f..52d7da4fd9d27f3263e9a526f6c263712c4d2790 100644 (file)
@@ -53,7 +53,7 @@
     </tr>
     <tr>
         <th>Rodelverleih</th>
     </tr>
     <tr>
         <th>Rodelverleih</th>
-        <td>${h.bool(c.sledding.sledge_rental)}</td>
+        <td>${h.bool(c.sledding.sled_rental)}</td>
     </tr>
     <tr>
         <th>Öffentliche Anreise</th>
     </tr>
     <tr>
         <th>Öffentliche Anreise</th>
index dc1992fa45f80c1723cee531fbc3e9ab3a5fde4f..05147b068d749371a220e16f17d6ddcffe8e92e6 100644 (file)
@@ -14,7 +14,7 @@
 
 <h2>WRGPX-Werkzeug</h2>
 
 
 <h2>WRGPX-Werkzeug</h2>
 
-<p><strong>Achtung: Da das WRGPX Format noch in Arbeit ist, ist diese Seite natürlich auch noch nicht fertig!</strong><p>
+<p><strong>Achtung: Da das WRGPX Format noch in Arbeit ist, ist diese Seite natürlich auch noch nicht fertig!</strong></p>
 
 <py:if test="not c.validated">
 <p>WRGPX steht für "Winterrodeln GPX". Hier können Sie eine .gpx Datei auf ihre Gültigkeit untersuchen.</p>
 
 <py:if test="not c.validated">
 <p>WRGPX steht für "Winterrodeln GPX". Hier können Sie eine .gpx Datei auf ihre Gültigkeit untersuchen.</p>
index c764688d3434a178fcd279735ae2749f1ae20f6f..df55e02faad68d1bb6f7166a48487562a1bed848 100644 (file)
@@ -1,4 +1,117 @@
+#!/usr/bin/python2.5
+# -*- coding: iso-8859-15 -*-
+# $Id$
 import wradmin.lib
 import wradmin.lib
+import wradmin.model
+
+
+def test_wikipage_to_wrsleddingcache1_2():
+    wiki_page = wradmin.model.Page()
+    wiki_page.page_id = 7
+    wiki_page.page_title = u"Kemater Alm"
+    wiki_page.old_text = u"""
+Text above
+{{Rodelbahnbox
+| Bild                 = Rodelbahn_Mitterer_Alm_04.jpg
+| Position             = 47.203959 N 11.308052 E
+| Länge                = 3500
+| Gehzeit              = 90
+| Höhe oben            = 2000
+| Höhe unten           = 1200
+| Aufstieg getrennt    = Ja
+| Lift                 = Nein
+| Beleuchtung          = Nein
+| Rodelverleih         = Ja
+| Öffentliche Anreise  = Nein
+| Lawinengefahr        = kaum
+| Auskunft             = 0664/5487520 (Mitterer Alm)
+| In Übersichtskarte   = Ja
+}}
+Text below"""
+    sledding_cache = wradmin.lib.mediawiki.wikipage_to_wrsleddingcache1_2(wiki_page)
+    assert sledding_cache.page_id == 7
+    assert sledding_cache.page_title == u"Kemater Alm"
+    assert sledding_cache.length == 3500
+    assert sledding_cache.walktime == 90
+    assert sledding_cache.height_top == 2000
+    assert sledding_cache.height_bottom == 1200
+    assert sledding_cache.walkup_separate == True
+    assert sledding_cache.lift == False
+    assert sledding_cache.night_light == False
+    assert sledding_cache.sledge_rental == True
+    assert sledding_cache.public_transport == False
+    assert sledding_cache.image == u"Rodelbahn_Mitterer_Alm_04.jpg"
+    assert sledding_cache.position_latitude == 47.203959
+    assert sledding_cache.position_longitude == 11.308052
+    assert sledding_cache.information == u"+43/664/5487520 (Mitterer Alm)"
+    # assert sledding_cache.forum_id
+    # assert sledding_cache.under_construction
+    assert sledding_cache.show_in_overview == True
+
+
+def test_wikipage_to_wrsleddingcache():
+    wiki_page = wradmin.model.Page()
+    wiki_page.page_id = 7
+    wiki_page.page_title = u"Kemater Alm"
+    wiki_page.old_text = u"""
+Text above
+{{Rodelbahnbox
+| Position             = 47.203959 N 11.308052 E
+| Position oben        = 
+| Höhe oben            = 1700
+| Position unten       = 
+| Höhe unten           = 1200
+| Länge                = 3500
+| Schwierigkeit        = mittel
+| Lawinen              = kaum
+| Betreiber            = Max Mustermann
+| Öffentliche Anreise  = Mittelmäßig
+| Gehzeit              = 90
+| Aufstieg getrennt    = Ja
+| Aufstiegshilfe       = Gondel (unterer Teil)
+| Beleuchtungsanlage   = Ja
+| Beleuchtungstage     = 3 (Montag, Mittwoch, Freitag)
+| Rodelverleih         = Ja (Talstation Serlesbahnan)
+| Gütesiegel           = Tiroler Naturrodelbahn-Gütesiegel 2009 mittel
+| Webauskunft          = http://www.nösslachhütte.at/page9.php
+| Telefonauskunft      = +43-664-5487520 (Mitterer Alm)
+| Bild                 = Rodelbahn_Mitterer_Alm_04.jpg
+| In Übersichtskarte   = Ja
+| Forumid              = 33
+}}
+Text below"""
+    sledding_cache = wradmin.lib.mediawiki.wikipage_to_wrsleddingcache(wiki_page)
+    assert sledding_cache.page_id == 7
+    assert sledding_cache.page_title == u"Kemater Alm"
+
+    assert sledding_cache.position_latitude == 47.203959
+    assert sledding_cache.position_longitude == 11.308052
+    assert sledding_cache.top_latitude == 47.203959
+    assert sledding_cache.top_longitude == 11.308052
+    assert sledding_cache.top_elevation == 2000
+    assert sledding_cache.bottom_latitude == 47.203959
+    assert sledding_cache.bottom_longitude == 11.308052
+    assert sledding_cache.bottom_elevation == 1200
+
+    assert sledding_cache.length == 3500
+    assert sledding_cache.walktime == 90
+    assert sledding_cache.walkup_separate == 1.0
+    sa.Column("walkup_separate_comment", types.Unicode(255)),    
+    assert sledding_cache.lift == False
+    sa.Column("lift_details", types.Unicode(255)),
+    assert sledding_cache.night_light == 1.0
+    sa.Column("night_light_days", types.Integer),
+    sa.Column("night_light_days_comment", types.Unicode(255)),
+    assert sledding_cache.sled_rental == True
+    assert sledding_cache.public_transport == 3
+    assert sledding_cache.avalanche = 1
+    assert sledding_cache.image == u"Rodelbahn_Mitterer_Alm_04.jpg"
+    assert sledding_cache.information == u"+43/664/5487520 (Mitterer Alm)"
+    assert sledding_cache.forum_threadid = 33
+    assert sledding_cache.show_in_overview == True
+
+    # assert sledding_cache.under_construction
+
 
 def test_mediawiki_users():
     users = wradmin.lib.mediawiki.MediaWikiUsers(True)
 
 def test_mediawiki_users():
     users = wradmin.lib.mediawiki.MediaWikiUsers(True)
index 01ca6cf1fd25ff41e5c7be6674abba302fe10ca0..96ca739969cfef4ed8dececa4c3720b582890a26 100644 (file)
@@ -72,4 +72,13 @@ def test_PhoneInfo():
             v.to_python(n) # has to throw an exception
             assert False, u"The telephone info '%s' should throw an exception." % n
         except formencode.Invalid: pass        
             v.to_python(n) # has to throw an exception
             assert False, u"The telephone info '%s' should throw an exception." % n
         except formencode.Invalid: pass        
-    
\ No newline at end of file
+
+def test_ValueCommentList():
+    v = wradmin.model.validators.ValueCommentList()
+    assert v.to_python('abc') == [('abc', None)]
+    assert v.to_python(u'abc def') == [(u'abc def', None)]
+    assert v.to_python('value (comment)') == [('value', 'comment')]
+    assert v.to_python(u'value (comment)') == [(u'value', u'comment')]
+    assert v.to_python('value1 (comment); value2') == [('value1', 'comment'), ('value2', None)]
+    assert v.to_python('value1 (comment1); value2; value3 (comment3)') == [('value1', 'comment1'), ('value2', None), ('value3', 'comment3')]
+    assert v.to_python('value1 (comment1); value2 (test (not easy))') == [('value1', 'comment1'), ('value2', 'test (not easy)')]
\ No newline at end of file