def inn_to_gasthausbox(inn):
"""Converts an inn class to a dict of Gasthausbox properties. value is an Inn instance."""
+ def convfromdb(value, key):
+ if value is None:
+ return None
+ return GASTHAUSBOX_DICT[key].from_str(value)
value = collections.OrderedDict()
value['Position'] = LonLat(inn.position_longitude, inn.position_latitude)
value['Höhe'] = inn.position_elevation
value['Übernachtung'] = (inn.overnight, inn.overnight_comment)
value['Rauchfrei'] = {(False, True): 0.0, (True, True): 0.5, (True, False): 1.0}.get((inn.nonsmoker_area, inn.smoker_area), None)
value['Rodelverleih'] = (inn.sled_rental, inn.sled_rental_comment)
- value['Handyempfang'] = inn.mobile_provider
- value['Homepage'] = inn.homepage
- value['E-Mail'] = inn.email_list
- value['Telefon'] = inn.phone_list
+ value['Handyempfang'] = convfromdb(inn.mobile_provider, 'Handyempfang')
+ value['Homepage'] = convfromdb(inn.homepage, 'Homepage')
+ value['E-Mail'] = convfromdb(inn.email_list, 'E-Mail')
+ value['Telefon'] = convfromdb(inn.phone_list, 'Telefon')
value['Bild'] = inn.image
- value['Rodelbahnen'] = inn.sledding_list
+ value['Rodelbahnen'] = convfromdb(inn.sledding_list, 'Rodelbahnen')
return value