def show_book(book_id): book = session.query(Book).filter_by(id=book_id).one_or_none() if book is not None: # Return a key called 'book' that contains just one book return jsonify(book=book.serialize) else: return 'The book with id {} does not exist!'.format(book_id)
def delete_book(book_id): book = session.query(Book).filter_by(id=book_id).one() if request.method == 'POST': session.delete(book) session.commit() return redirect(url_for('show_books')) else: return render_template('delete_book.html', book=book)
def delete_book(book_id): book = session.query(Book).filter_by(id=book_id).one_or_none() if book is not None: session.delete(book) session.commit() return 'The book with id {} was deleted'.format(book_id) else: return 'The book with id {} does not exist!'.format(book_id)
def get_all(): wine_attributes = [] try: wine_attributes = session.query(WineAttribute).all() except Exception as e: print(e) finally: session.close() return WineAttributeSchema().dump(wine_attributes, many=True)
def update_book(book_id): book = session.query(Book).filter_by(id=book_id).one() # Validate method and not null fields for the book if request.method == 'POST' and request.form['title'] and request.form[ 'author']: book.title = request.form['title'] book.author = request.form['author'] book.genres = request.form['genres'] session.add(book) session.commit() return redirect(url_for('show_books')) else: return render_template('update_book.html', book=book)
def update_book(book_id): #request.json['title'] title = request.args.get('title', '') author = request.args.get('author', '') genres = request.args.get('genres', '') book = session.query(Book).filter_by(id=book_id).one_or_none() # Validate book and not null fields for it if book is not None and title and author: book.title = title book.author = author book.genres = genres session.add(book) session.commit() # Return a key called 'book' that contains the updated book return jsonify(book=book.serialize) else: return 'Error trying to update the book! Please, check the params..'
def show_books(): books = session.query(Book).all() return render_template("show_books.html", books=books)
def show_books(): books = session.query(Book).all() # Return a key called 'books' that contains a list of books return jsonify(books=[b.serialize for b in books])
def get_by_prefix(prefix): return session.query(IP).filter("prefix=:prefix").params(prefix=prefix).all()
def get_idcs(idc): return session.query(Asset)
def get_by_id(id): return session.query(Asset).filter("id=:id").params(id=id).all()
def get_idcs(idc): return session.query(IDC)
def get_idcs(idc): return session.query(sys_op_ship)
def get_by_id(id): return session.query(sys_op_ship).filter("id=:id").params(id=id).all()