def create_flight(jwt): body = request.get_json() origin = body.get('origin', None) destination = body.get('destination', None) time = body.get('time', None) booked = body.get('booked', None) trip = body.get('trip', None) if (origin is None or destination is None or trip is None or origin == '' or destination == '' or trip == ''): abort(400) db_trip = Trip.query.get(trip) if (db_trip is None): abort(400) try: new_flight = Flight(origin=origin, destination=destination, time=time, booked=booked, trip=trip) new_flight.insert() return jsonify({'success': True, 'flight_id': new_flight.id}) except: abort(422)
def add_Flight(): try: data = json.loads(request.data) flight = Flight(SpaceShip=data['spaceship'], Station=data['station'], LaunchingPad=data['launchingpad'], LaunchingDate=data['launchingdate']) Flight.insert(flight) except BaseException: print('aborted') abort(422) return paginate_flights()