def purchaseticketForUser(): if checkSession() == False: return redirect('login') p = passengerList() if p.checkNotUser('Passenger', session['user']['PEmail']): if request.form.get('Destination') is None: #print('hi') t = tripList() stations = t.getStations() date = request.form.get('departDate') Origin = request.form.get('Origin') Destination = request.form.get('Destination') #print(date) #print(Origin) #print(Destination) s = trainStationList() s.getAll() return render_template('purchaseticketForUser.html', title="Search for Ticket", stations=s.data) else: s = trainStationList() s.getAll() t = tripList() stations = t.getStations() date = request.form['departDate'] Origin = request.form['Origin'] Destination = request.form['Destination'] User = request.form['User'] #print(date) if not t.checkPurchase(date, User): return render_template('purchaseticketForUser.html', title="Search for Ticket", stations=s.data, msg=t.errorList) else: t.getTrips(Destination, date, Origin) #print(date) #print(Origin) #print(Destination) #return info for search write SQL function in trips return render_template('searchU.html', title="Search for Ticket", trips=t.data, user=User) else: return redirect('main')
def buyTicketU(): if checkSession() == False: return redirect('login') p = passengerList() if p.checkNotUser('Passenger', session['user']['PEmail']): #Need to get tripID, seattype, price, and PID if request.form.get('tripInfo') is None: return render_template('searchU.html', title="No Ticket Selected") else: tripInfo = request.form.get('tripInfo') splitTripInfo = tripInfo.split(',') t = ticketList() tr = tripList() print(splitTripInfo) t.set('seatType', splitTripInfo[1]) t.set('price', splitTripInfo[2]) t.set('PID', splitTripInfo[3]) t.set('tripID', splitTripInfo[0]) t.add() t.insert() if splitTripInfo[1] == 'GeneralTicket': tr.updatePassengers('numOfGPassengers', splitTripInfo[0]) elif splitTripInfo[1] == 'BusinessTicket': tr.updatePassengers('numOfBPassengers', splitTripInfo[0]) elif splitTripInfo[1] == 'FirstClassTicket': tr.updatePassengers('numOfFPassengers', splitTripInfo[0]) return render_template('admin.html', title="Ticket Purchased") else: return redirect('main')
def seetripboard(): if checkSession() == False: return redirect('login') t = tripList() t.getAll() #print(t.data) return render_template('seetripboard.html', title="Today's Trips", trips=t.data)
def purchaseTicket(): if checkSession() == False: return redirect('login') if request.form.get('Destination') is None: #print('hi') t = tripList() stations = t.getStations() date = request.form.get('departDate') Origin = request.form.get('Origin') Destination = request.form.get('Destination') #print(date) #print(Origin) #print(Destination) s = trainStationList() s.getAll() return render_template('purchaseticket.html', title="Search for Ticket", stations=s.data) else: t = tripList() stations = t.getStations() date = request.form['departDate'] Origin = request.form['Origin'] Destination = request.form['Destination'] t.getTrips(Destination, date, Origin) #print(date) #print(Origin) #print(Destination) #return info for search write SQL function in trips s = trainStationList() s.getAll() if not t.checkPurchase(date, session['user']['PID']): return render_template('purchaseticket.html', title="Search for Ticket", stations=s.data, msg=t.errorList) else: return render_template('search.html', title="Search for Ticket", trips=t.data)
def tripInfo(): if checkSession() == False: return redirect('login') p = passengerList() if p.checkNotUser('Passenger', session['user']['PEmail']): if request.form.get('departDate') is None: #print('hi') t = tripList() stations = t.getStations() date = request.form.get('departDate') Origin = request.form.get('Origin') Destination = request.form.get('Destination') #print(date) #print(Origin) #print(Destination) s = trainStationList() s.getAll() return render_template('tripinfo.html', title="Search for Trips", stations=s.data) else: t = tripList() stations = t.getStations() date = request.form['departDate'] Origin = request.form['Origin'] Destination = request.form['Destination'] print(date) print(Destination) t.getTrips(Destination, date, Origin) #print(date) #print(Origin) #print(Destination) #return info for search write SQL function in trips return render_template('tripsearch.html', title="Search for Trip", trips=t.data) else: return redirect('main')
def updatetrip(): p = passengerList() if checkSession() == False: return redirect('login') if p.checkUser('Admin', session['user']['PEmail']): if request.form.get('delayedStatus') is None: t = tripList() t.set('Origin', '') t.set('Destination', '') t.set('delayedDepartDateTime', '') t.set('delayedArrivalDateTime', '') t.set('departDateTime', '') t.set('departDateTime', '') t.set('trainID', '') t.set('delayedStatus', '') t.add() return render_template('updatetrip.html', title='New Trip', train=t.data[0]) else: t = tripList() t.set('tripID', request.form.get('tripID')) t.set( 'delayedDepartDateTime', request.form.get('departDate') + ' ' + request.form.get('departTime')) t.set( 'delayedArrivalDateTime', request.form.get('arrivalDate') + ' ' + request.form.get('arrivalTime')) t.set('trainID', request.form.get('trainID')) t.set('delayedStatus', request.form.get('delayedStatus')) t.update(0, 'tripID', request.form.get('tripID')) t.update( 0, 'delayedDepartDateTime', request.form.get('departDate') + ' ' + request.form.get('departTime')) t.update( 0, 'delayedArrivalDateTime', request.form.get('arrivalDate') + ' ' + request.form.get('arrivalTime')) t.update(0, 'trainID', request.form.get('trainID')) t.update(0, 'delayedStatus', request.form.get('delayedStatus')) t.add() if t.verifyNew(): if t.verifyPossibleTrip() and t.CheckTrainID( request.form.get('trainID')) and t.CheckTripID( request.form.get('tripID')): #print(t.data[0]) t.updateSQL() return render_template('admin.html', title='Trip Saved!', train=t.data[0]) else: #print(t.data[0]) return render_template('updatetrip.html', title='Trip Not Saved!', train=t.data[0], msg=t.errorList) else: print(t.data[0]) #print('hi') return render_template('updatetrip.html', title='Trip Not Saved!', train=t.data[0], msg=t.errorList) else: return redirect('main')
def addtrip(): p = passengerList() if checkSession() == False: return redirect('login') if p.checkUser('Admin', session['user']['PEmail']): if request.form.get('Origin') is None: t = tripList() t.set('Origin', '') t.set('Destination', '') t.set('delayedDepartDateTime', '') t.set('delayedArrivalDateTime', '') t.set('departDateTime', '') t.set('departDateTime', '') t.set('trainID', '') t.set('numOfGPassengers', '') t.set('numOfBPassengers', '') t.set('numOfFPassengers', '') t.set('delayedStatus', '') t.add() s = trainStationList() s.getAll() #stations = t.getStations() t.getTrain() #print(stations) return render_template('addtrip.html', title='New Trip', train=t.data[0], stations=s.data) else: t = tripList() t.set('Origin', request.form['Origin']) t.set('Destination', request.form['Destination']) t.set( 'departDateTime', request.form.get('departDate') + ' ' + request.form.get('departTime')) t.set( 'arrivalDateTime', request.form.get('arrivalDate') + ' ' + request.form.get('arrivalTime')) t.set('trainID', request.form.get('trainID')) t.set('numOfGPassengers', 0) t.set('numOfBPassengers', 0) t.set('numOfFPassengers', 0) t.set('delayedStatus', 'On Time') t.add() s = trainStationList() s.getAll() if t.verifyNew(): if t.verifyPossibleTrip() and t.CheckTrainID( request.form.get('trainID')): #print(t.data[0]) t.insert() return render_template('admin.html', title='Trip Saved!', train=t.data[0]) else: #print(t.data[0]) return render_template('addtrip.html', title='Trip Not Saved!', train=t.data[0], msg=t.errorList, stations=s.data) else: #print(t.data[0]) return render_template('addtrip.html', title='Trip Not Saved!', train=t.data[0], msg=t.errorList, stations=s.data) else: return redirect('main')