Example #1
0
def drivers():
    drivers = DriverHandler().getAllDrivers()

    if drivers:
        return render_template('drivers.html', drivers=drivers)

    msg = "No Drivers Found"
    return render_template('drivers.html', msg=msg)
Example #2
0
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)
Example #3
0
def getDriverContacts(phone):
    if request.method == 'GET':
        return DriverHandler().getDriverByPhone(phone)
Example #4
0
def getDriverByLicense(license):
    if request.method == 'GET':
        return DriverHandler().getDriverByLicense(license)
Example #5
0
def getDriverByName(first_name, last_name):
    if request.method == 'GET':
        return DriverHandler().getDriversByName(first_name, last_name)
Example #6
0
def getDriversByLastName(last_name):
    if request.method == 'GET':
        return DriverHandler().getDriversByLastName(last_name)
Example #7
0
def getDriverById(driver_id):
    if request.method == 'GET':
        return DriverHandler().getDriverById(driver_id)
    else:
        return jsonify(Error="Method not allowed."), 405
Example #8
0
def getAllDrivers():
    if request.method == 'GET':
        return DriverHandler().getAllDrivers()