Exemplo n.º 1
0
def search_for_customer(form):
    for key in customer_heads:
        customer = Customer.search(form[key])
        if customer:
            return customer

    return None
Exemplo n.º 2
0
def sidebar():
    search_term = request.args["sidebar-search-term"]
    customer = Customer.search(search_term)
    if customer:
        return redirect(
            url_for('customer.profile', id=customer.id)
        )

    return redirect(
        session['prev_uri']
    )
Exemplo n.º 3
0
def customers():
    customers = Customer.get_all()
    autocomplete_data = [customer.name for customer in customers]
    placeholder = "Escribe el nombre o el email del cliente que buscas..."
    if request.method == "POST":
        search_term = request.form["search_term"]
        customer = Customer.search(search_term)
        if customer:
            return redirect(url_for('customer.profile', id=customer.id))
        else:
            flash("No se encontró ningún cliente")

    return render_template('customer/customers.html',
                           customers=customers,
                           heads=customer_heads,
                           autocomplete_data=autocomplete_data,
                           placeholder=placeholder)