def index(): books = book_repo.select_all() authors = author_repo.select_all() return render_template('index.html', title='Home', books=books, authors=authors)
import pdb from models.author import Author from models.book import Book import repositories.author_repository as author_repository import repositories.book_repository as book_repository author_1 = Author("J.R.R. Tolkien", 5) author_repository.save(author_1) book_1 = Book("The Fellowship of the Rings", author_1, 1954) book_repository.save(book_1) print(book_1.id) book_2 = Book("The Two Towers", author_1, 1954) book_repository.save(book_2) book_3 = Book("The Return of the King", author_1, 1955) book_repository.save(book_3) book_4 = Book("The Silmarillion", author_1, 1977) book_repository.save(book_4) print(author_repository.select_all()) print(book_repository.select_all()) pdb.set_trace()
import pdb from models.author import Author from models.book import Book import repositories.author_repository as author_repository import repositories.book_repository as book_repository author_repository.delete_all() book_repository.delete_all() author1 = Author("Kurt", "Vonnegut") author_repository.save(author1) author2 = Author("Brandon", "Sanderson") author_repository.save(author2) author_repository.select_all() book1 = Book("Cats Cradle", "satire", 1963) book_repository.save(book1) book2 = Book("Breakfast of Champions", "satire", 1973) book_repository.save(book2) book3 = Book("The Way of Kings", "High Fantasy", 2010) book_repository.save(book3) book4 = Book("Words of Radiance", "High Fantasy", 2014) book_repository.save(book4) pdb.set_trace()
def edit_book(id): book = book_repository.select(id) authors = author_repository.select_all() return render_template("books/edit.html", book=book, all_authors=authors)
def new_book(): authors = author_repository.select_all() return render_template("books/new.html", all_authors=authors)
def authors_index(): authors = author_repo.select_all() return render_template('author/index.html', title='Authors', authors=authors)
def edit_book(): authors = author_repository.select_all() book = book_repository.select(request.form['book_id']) return render_template("books/edit.html", book = book, authors = authors)
def create_book(): authors = author_repository.select_all() return render_template('books/new.html', all_authors=authors)
def edit(id): book = book_repository.select(id) authors = author_repository.select_all() return render_template('books/edit.html', book=book, authors=authors)
def add_book(): authors = author_repo.select_all() return render_template('/book/add.html', title='Add a book', authors=authors)
def library(): authors = author_repository.select_all() books = book_repository.select_all() return render_template("index.html", authors=authors, books=books)