Ejemplo n.º 1
0
def index():
    form = form_handler.SearchBooksForm(request.form)
    form_valid = form.validate()
    if request.method == "POST" and form_valid:
        books = db_handler.get_books(form.search_by_title.data, 
                                    form.search_by_author.data)
    else:
        books = db_handler.get_all_books()
        for field in form:
            for error in field.errors:
                flash(error)
        if not form_valid:
            form.search_by_title.data = ""
            form.search_by_author.data = ""
    return render_template("list_books.html", books = books, form=form)
Ejemplo n.º 2
0
def index():
    form = form_handler.SearchBooksForm(request.form)
    form_valid = form.validate()
    if request.method == "POST" and form_valid:
        books = db_handler.get_books(form.search_by_title.data,
                                     form.search_by_author.data)
    else:
        books = db_handler.get_all_books()
        for field in form:
            for error in field.errors:
                flash(error)
        if not form_valid:
            form.search_by_title.data = ""
            form.search_by_author.data = ""
    return render_template("list_books.html", books=books, form=form)