def update_driver_location(itinerary_id): data = request.get_json() itinerary = Itinerary.get_by_key(itinerary_id) if not itinerary: return jsonify({'errors': ['Itinerary not found']}), 404 driver = Driver.get_by_email(g.user['email']) if not driver: return jsonify({'errors': ['Driver not found.']}), 404 itinerary.update_driver_location(data) Itinerary.update(itinerary) return jsonify({'id': itinerary_id}), 201
def add_partner(itinerary_id): data = request.get_json() print(data) itinerary = Itinerary.get_by_key(itinerary_id) if not itinerary: return jsonify({'errors': ['Itinerary not found']}), 404 '''schema = ItineraryAddPartnerSchema(strict=True) data, errors = schema.load(data) if errors: return jsonify({ 'errors': errors }), 409''' driver = Driver.get_by_email(data['name']) if not driver: return jsonify({'errors': ['Driver not found.']}), 404 itinerary.add_partner(driver) Itinerary.update(itinerary) return jsonify({'id': itinerary_id}), 201