def book_edit(book_id): book = None if book_id == 'new': book = create_empty_book() else: book = search_book_by_id(container, book_id) return render_template('book-edit.html', book=book)
def book_edit(id): book = None if id == 'new': book = create_empty_book() else: book = search_book_by_id(books_list, id) return render_template('book-edit.html', book=book)
def book_save(book_id): nonlocal container title = request.form['title'] author = request.form['author'] if book_id == 'new': book = create_book(title=title, author=author) container = add_book(container, book) else: book = search_book_by_id(container, book_id) pass # TODO сохранить изменеия return redirect(url_for('book_details', book_id=book['id']))
def book_save(book_id): nonlocal container title = request.form['title'] author = request.form['author'] price = request.form['price'] tags = request.form['tags'] if book_id == 'new': book = create_book(title=title, author=author, price=price, tags=tags) container = add_book(container, book) else: book = search_book_by_id(container, book_id) update_book(book, title=title, author=author, price=price, tags=tags) # pass # TODO: сохранить измения return redirect(url_for('book_details', book_id=book['id']))
def book_details(book_id): result = search_book_by_id(container, book_id) return render_template('book-details.html', book=result)
def book_details(id): result = search_book_by_id(books_list, id) return render_template('book-details.html', book=result)