def get_child_passengers(member_dict, member): children_phone_numbers = member_dict["children_phone_numbers"].split("\n") for child_phone_number in children_phone_numbers: child_passenger = Passenger() child_passenger.member = member child_passenger.passenger_type = "child" child_passenger.phone_number = clean_phone_number(child_phone_number) yield child_passenger
def get_main_passenger(member_dict, member): # The passenger can already exist if it was a spouse of a previous passenger main_passenger = Passenger.query.filter(Passenger.phone_number==member_dict["phone_number"]).first() if not (main_passenger and main_passenger.passenger_type == "spouse"): main_passenger = Passenger() main_passenger.member = member member_dict["phone_number"] = clean_phone_number(member_dict["phone_number"]) member_dict["id_number"] = clean_id_number(member_dict["id_number"]) main_passenger_attributes = ("last_name", "first_name", "phone_number", "id_number") for passenger_attribute in main_passenger_attributes: save_string(member_dict, main_passenger, passenger_attribute) save_bool(member_dict, main_passenger, "has_smartphone") main_passenger.passenger_type = "member" return main_passenger
def get_spouse_passenger(member_dict, member): spouse_passenger = Passenger() spouse_passenger.member = member spouse_passenger.passenger_type = "spouse" spouse_passenger.phone_number = clean_phone_number(member_dict["spouse_phone_number"]) return spouse_passenger