def trolleys(): trolleys = TrolleyHandler().getAllTrolleys() if trolleys: return render_template('trolleys.html', trolleys=trolleys) msg = "No Trolleys Found" return render_template('trolleys.html', msg=msg)
def delete_trolley(trolley_id): trolley_id = TrolleyHandler().deleteTrolley(trolley_id) if trolley_id: flash('Trolley Deleted', 'success') return redirect(url_for('trolleys')) msg = "No Trolley Found" return render_template('trolleys.html', msg=msg)
def add_trolley(): if request.method == 'POST': form = request.form plate = form['plate'] capacity = form['capacity'] mileage = form['mileage'] trolley = TrolleyHandler().registerTrolley(plate, capacity, mileage) if trolley: flash('Trolley Added', 'success') return redirect(url_for('trolleys')) msg = "Method Not Allowed" return render_template('trolleys.html', msg=msg)
def create_itinerary(): form = ItineraryForm(request.form) form.driver_id.choices = [(driver['driver_id'], driver['name']) for driver in DriverHandler().getAllDrivers()] form.trolley_id.choices = [ (trolley['trolley_id'], trolley['plate']) for trolley in TrolleyHandler().getAllTrolleys() ] form.route_id.choices = [(route['route_id'], route['route_name']) for route in RouteHandler().getAllRoutes()] if request.method == 'POST': date = form.date.data start_time = form.start_time.data end_time = form.end_time.data driver_id = form.driver_id.data trolley_id = form.trolley_id.data route_id = form.route_id.data print(date) print(start_time) print(end_time) print(driver_id) print(trolley_id) print(route_id) itinerary = ItineraryHandler().createItinerary(date, start_time, end_time, driver_id, trolley_id, route_id) if itinerary: flash('Itinerary Created', 'success') return redirect(url_for('itineraries')) elif request.method == 'GET': return render_template('create_itinerary.html', form=form) msg = "Method Not Allowed" return render_template('create_itinerary.html', msg=msg)
def getTrolleyByPlate(plate): if request.method == 'GET': return TrolleyHandler().getTrolleyByPlate(plate)
def getTrolleyById(trolley_id): if request.method == 'GET': return TrolleyHandler().getTrolleyById(trolley_id)
def getAllTrolleys(): if request.method == 'GET': return TrolleyHandler().getAllTrolleys()
def getTrolleysByMileageRange(mileage_low, mileage_high): if request.method == 'GET': return TrolleyHandler().getTrolleysByMileageRange( mileage_low, mileage_high)
def getTrolleysByCapacity(capacity): if request.method == 'GET': return TrolleyHandler().getTrolleysByCapacity(capacity)