import wrpylib.wrmwdb
from wrpylib.wrvalidators import LonLat, opt_lonlat_from_str, opt_lonlat_to_str, opt_uint_from_str, opt_uint_to_str, \
opt_str_opt_comment_enum_to_str, lift_german_to_str, webauskunft_to_str, cachet_german_to_str, \
- opt_phone_comment_enum_to_str, lift_german_from_str
+ opt_phone_comment_enum_to_str, lift_german_from_str, GASTHAUSBOX_DICT
def sledrun_from_rodelbahnbox(value, sledrun):
def inn_from_gasthausbox(value, inn):
"""Converts a dict with Gasthausbox properties to a Inn class. Does no validation.
value is a dict of properties as returned by gasthausbox_from_str."""
+ # page_id = None # this field is not updated because it is not present in the Gasthausbox
+ # page_title = None # this field is not updated because it is not present in the Gasthausbox
+ def convtodb(value, key):
+ v = value[key]
+ if v is not None:
+ v = GASTHAUSBOX_DICT[key].to_str(v)
+ return v
inn.position_longitude, inn.position_latitude = value['Position']
inn.position_elevation = value['Höhe']
inn.operator = value['Betreiber']
inn.seats = value['Sitzplätze']
inn.overnight, inn.overnight_comment = value['Übernachtung']
- inn.nonsmoker_area, inn.smoker_area = value['Rauchfrei']
+ inn.smoker_area = value['Rauchfrei'] < 0.9
+ inn.nonsmoker_area = value['Rauchfrei'] > 0.1
inn.sled_rental, inn.sled_rental_comment = value['Rodelverleih']
- inn.mobile_provider = value['Handyempfang']
- inn.homepage = value['Homepage']
- inn.email_list = value['E-Mail']
- inn.phone_list = value['Telefon']
+ inn.mobile_provider = convtodb(value, 'Handyempfang')
+ inn.homepage = convtodb(value, 'Homepage')
+ inn.email_list = convtodb(value, 'E-Mail')
+ inn.phone_list = convtodb(value, 'Telefon')
inn.image = value['Bild']
- inn.sledding_list = value['Rodelbahnen']
+ inn.sledding_list = convtodb(value, 'Rodelbahnen')
+ # under_construction = None # this field is not updated because it is not present in the GasthausBox
return inn