Exemplo n.º 1
0
def search_by():
    def filter_by(criteria, name, book):
        return name in book[criteria].lower()
    
    set_db()
    books = Book.allMeta()
    criteria = request.form.get('busqueda')
    name = request.form.get('nombre').lower()
    selected = list(filter(lambda book: filter_by(criteria, name, book), books))

    return selected
Exemplo n.º 2
0
def search():
    def filter_by(criteria, name, book):
        return name in book[criteria].lower()

    set_db()
    books = Book.allMeta()
    criteria = request.form.get('busqueda')
    name = request.form.get('nombre').lower()
    print(name)
    selected = list(filter(lambda book: filter_by(criteria, name, book), books))
    print(selected)
    venc = list(map(lambda meta: validate_date(meta['isbn']), selected))
    hasChapters = list(map(lambda meta: Book.allChapter(meta['isbn'])!=(), selected))
    i = int(request.args.get('i',0))
    Configuracion.db = get_db()
    pag=Configuracion.get_page_size()
    if (i == -1):
        i=0
    elif (i*pag >= len(books)):
        i = i - 1
    adm = "configuracion_usarInhabilitado" in session['permisos'] #Permiso que solo tiene un administrador
    return render_template('books/menu.html', books=selected, i=i, pag=pag, adm=adm, canReadBook=venc, hasChapters=hasChapters)