示例#1
0
def cars():
    """
    Task 2: At the moment this endpoint does not do anything if a search
    is sent. It should filter the cars depending on the search criteria
    """
    name = request.form.get('make', '')
    model = request.form.get('model' '')
    cars = system.car_search(name, model)
    return render_template('cars.html', cars=cars)
示例#2
0
文件: routes.py 项目: A-Dajon/lab09
def cars():
    """
    Task 2: At the moment this endpoint does not do anything if a search
    is sent. It should filter the cars depending on the search criteria
    """
    cars = system.cars    
    if request.method == 'POST':
        make = request.form["make"]
        model = request.form["model"]       
        cars = system.car_search(make, model)
    return render_template('cars.html', cars = cars)
示例#3
0
def cars():
    """
    Task 2: At the moment this endpoint does not do anything if a search
    is sent. It should filter the cars depending on the search criteria
    """
    if request.method == 'POST':
        name = request.form['make']
        model = request.form['model']
        cars = system.car_search(name, model)
        return render_template('cars.html', cars=cars)
    cars = system.cars  # This line is deleted in the model solution
    return render_template('cars.html', cars=cars)
示例#4
0
def cars():
    """
    Task 2: At the moment this endpoint does not do anything if a search
    is sent. It should filter the cars depending on the search criteria
    """
    #  cars = system.cars
    make = request.args.get('make')
    model = request.args.get('model')
    if make == '':
        make = None
    if model == '':
        model = None
    cars = system.car_search(make, model)
    return render_template('cars.html', cars=cars)
示例#5
0
def cars():
    """
    Task 2: At the moment this endpoint does not do anything if a search
    is sent. It should filter the cars depending on the search criteria
    """
    #-----------added start-------------
    #get keyword from url
    name = request.args.get("make")
    model = request.args.get("model")
    if current_user.is_admin():
        cars = system.cars
    else:
        cars = system.car_search(name, model)

    ##cars = system.cars
    #----------added end--------------
    return render_template('cars.html', cars=cars)