def insertFlight(): departure = request.form.get('departure') arrival = request.form.get('arrival') idPlane = request.form.get('idPlane') flightDepartureDatetime = request.form.get('flightDepartureDatetime') flightArrivalDatetime = request.form.get('flightArrivalDatetime') percentDiscount = request.form.get('percentDiscount') plane = Plane.SelectPlaneID(idPlane) flight = Flight("NULL", departure, arrival, plane, flightDepartureDatetime, flightArrivalDatetime, percentDiscount) flight.InsertFlight() return redirect('/flight')
def confirmarReserva(): idFlight = request.args.get('idFlight') idSeat = request.args.get('idSeat') flight = Flight.SelectFlightsID(idFlight) return render_template('personalizarViaje.html', flight=flight, idSeat=idSeat)
def elegirSalida(): listaVuelos = Flight.SelectFlights() listaSalidas = [] for item in listaVuelos: if item.departure not in listaSalidas: listaSalidas.append(item.departure) return render_template('elegirSalida.html', listaSalidas=listaSalidas)
def insertFlightUser(): idFlight = request.form.get('idFlight') idUser = request.form.get('idUser') seatNumber = request.form.get('seatNumber') flight = Flight.SelectFlightsID(idFlight) user = User.SelectUserID(idUser) seat = Seats.SelectSeatsID(seatNumber) flightUser = FlightUser(flight, user, seat) flightUser.InsertFlightUser() return redirect('/flightUser')
def reservarViaje(): idFlight = request.form.get('idFlight') idSeat = request.form.get('idSeat') flight = Flight.SelectFlightsID(idFlight) user = User.SelectUserID(session['idUser']) seat = Seats.SelectSeatsID(idSeat) flightUser = FlightUser(flight, user, seat) if flightUser not in FlightUser.SelectFlightUser(): flightUser.InsertFlightUser() return redirect('home')
def elegirLLegada(): salida = request.form.get('salida') listaFlight = Flight.BuscarSalida(salida) listaLLegadas = [] for item in listaFlight: if item.arrival not in listaLLegadas: listaLLegadas.append(item.arrival) return render_template('elegirLLegada.html', listaLLegadas=listaLLegadas, salida=salida)
def personalizarViaje(): salida = request.form.get('salida') llegada = request.form.get('llegada') fechaIda = request.form.get('fechaIda') fechaVuelta = request.form.get('fechaVuelta') idSeat = request.form.get('asiento') flight = Flight.BuscarViaje(salida, llegada, fechaIda, fechaVuelta) return render_template('personalizarViaje.html', flight=flight, idSeat=idSeat)
def editFlightUser(): oldIDFlight = request.form.get('oldIDFlight') oldIDUser = request.form.get('oldIDUser') idFlight = request.form.get('idFlight') idUser = request.form.get('idUser') seatNumber = request.form.get('seatNumber') flight = Flight.SelectFlightsID(idFlight) user = User.SelectUserID(idUser) seat = Seats.SelectSeatsID(seatNumber) flightUser = FlightUser.SelectFlightUserID(oldIDFlight, oldIDUser) flightUser.UpdateFlightUser(flight, user, seat) return redirect('/flightUser')
def elegirFechaIda(): salida = request.form.get('salida') llegada = request.form.get('llegada') listaFlight = Flight.BuscarSalidaLLegada(salida, llegada) listaFechaIda = [] for item in listaFlight: if item.flightDepartureDatetime not in listaFechaIda: listaFechaIda.append(item.flightDepartureDatetime) return render_template('elegirFechaIda.html', listaFechaIda=listaFechaIda, llegada=llegada, salida=salida)
def editFlight(): idFlight = request.form.get('idFlight') departure = request.form.get('departure') arrival = request.form.get('arrival') idPlane = request.form.get('idPlane') flightDepartureDatetime = request.form.get('flightDepartureDatetime') flightArrivalDatetime = request.form.get('flightArrivalDatetime') percentDiscount = request.form.get('percentDiscount') plane = Plane.SelectPlaneID(idPlane) flight = Flight.SelectFlightsID(idFlight) flight.UpdateFlight(departure, arrival, plane, flightDepartureDatetime, flightArrivalDatetime, percentDiscount) return redirect('/flight')
def elegirAsiento(): salida = request.form.get('salida') llegada = request.form.get('llegada') fechaIda = request.form.get('fechaIda') fechaVuelta = request.form.get('fechaVuelta') listaFlight = Flight.BuscarSalidaLLegadaFechaIdaFechaVuelta( salida, llegada, fechaIda, fechaVuelta) asientos = Seats.SelectSeats() listaAsientos = [] for item in listaFlight: for item2 in asientos: if item2.Model.code == item.Plane.Model.code: listaAsientos.append(item2) return render_template('elegirAsiento.html', listaAsientos=listaAsientos, salida=salida, llegada=llegada, fechaIda=fechaIda, fechaVuelta=fechaVuelta)
def deleteFlight(): idFlight = request.args.get('idFlight') Flight.DeleteFlight(idFlight) return redirect('/flight')
def flight(): listaFlight = Flight.SelectFlights() return render_template('Flight.html', listaFlight=listaFlight)
idUser = request.form.get('idUser') seatNumber = request.form.get('seatNumber') flight = Flight.SelectFlightsID(idFlight) user = User.SelectUserID(idUser) seat = Seats.SelectSeatsID(seatNumber) flightUser = FlightUser.SelectFlightUserID(oldIDFlight, oldIDUser) flightUser.UpdateFlightUser(flight, user, seat) return redirect('/flightUser') @app.route('/flightUser/deleteFlightUser', methods=['GET']) def deleteFlightUser(): idFlight = request.args.get('idFlight') idUser = request.args.get('idUser') FlightUser.DeleteFlightUser(idFlight, idUser) return redirect('/flightUser') if __name__ == '__main__': app.run(debug=True) listaVuelos = Flight.SelectFlights() listaSalidas = [] for item in listaVuelos: if item.departure not in listaSalidas: listaSalidas.append(item.departure) print(item.idFlight) print(item.departure) for item in listaSalidas: pass
def GetFlightUser(dic): flight = Flight.SelectFlightsID(dic["idFlight"]) user = User.SelectUserID(dic["idUser"]) seat = Seats.SelectSeatsID(dic["seatNumber"]) return flight, user, seat