def from_json(json): if json: item = Location( id=json.get('id'), address=json.get('address'), city=json.get('city'), postal_code=json.get('postal_code'), state_code=json.get('state_code'), coordinate=Coordinate.from_json(json.get('coordinate')), coordinate_id=json.get("coordinate", {}).get("id") ) return item return None
def from_json(json, user): plan = Plan( name=json.get("name"), start_time=datetime.strptime(json.get("start_time"), "%Y-%m-%d %H:%M:%S %z") if json.get("start_time") is not None else None, end_time=datetime.strptime(json.get("end_time"), "%Y-%m-%d %H:%M:%S %z") if json.get("end_time") is not None else None, public=json.get("public"), starting_address=json.get("starting_address"), starting_coordinate=Coordinate.from_json(json.get("starting_coordinate")), description=json.get("description"), user=user, ) return plan