Example #1
0
def index():
    books = book_repo.select_all()
    authors = author_repo.select_all()
    return render_template('index.html',
                           title='Home',
                           books=books,
                           authors=authors)
Example #2
0
def create_book():
    book_list = book_repository.select_all()
    for book in book_list:
        if book.author.name == request.form["author"]:
            new_book = Book(request.form["title"], book.author)
            book_repository.save(new_book)
            return
        else:
            new_author = Author(request.form["author"])
            author_repository.save(new_author)
            new_book = Book(request.form["title"], new_author)
            book_repository.save(new_book)

    return redirect("/books")
Example #3
0
def books():
    books = book_repository.select_all()
    return render_template("books/index.html", all_books=books)
Example #4
0
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()
Example #5
0
def new_book():
    books = book_repository.select_all()
    return render_template("books/new.html", new_book=books)
def books():
    # get all the tasks from the DB using the repository functions
    books = book_repository.select_all()
    return render_template("books/index.html", all_books=books)
def books():
    # Get all tasks from the db
    books = book_repository.select_all()
    return render_template('books/index.html', all_books=books)
Example #8
0
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('Roald Dahl')
author_repository.save(author_1)
author_2 = Author('Fyodor Dostoevsky')
author_repository.save(author_2)

author_repository.select_all()


book_1 = Book('BFG', 'children')
book_repository.save(book_1)
book_2 = Book('Crime and Punishment', 'drama')
book_repository.save(book_2)

book_repository.select_all()

pdb.set_trace()
def book_index():
    books = book_repo.select_all()
    return render_template('book/index.html', title='Books', books=books)
def authors():
    # Get all tasks from the db
    books = book_repository.select_all()
    return render_template("books/index.html", books=books)
Example #11
0
import pdb
from models.book import Book
from models.author import Author
import repositories.book_repository as book_repository
import repositories.author_repository as author_repository

book_repository.delete_all()
author_repository.delete_all()

author_1 = Author("Terry", "Pratchet")
author_repository.new_author(author_1)

book_1 = Book("The Colour of Magic", "Fantasy", "Colin Smythe", author_1)
book_repository.new_book(book_1)

author_2 = Author("Candace", "Pert")
author_repository.new_author(author_2)

book_2 = Book("Molecules of Emotion", "Neuroscience", "Simon & Schuster UK",
              author_2)
book_repository.new_book(book_2)

book_3 = Book("Mort", "Fantasy", "Colin Smythe", author_1)
book_repository.new_book(book_3)

for book in book_repository.select_all():
    print(book.__dict__)

# for author in author_repository.select_all():
#     print(author.__dict__)
def library():
    authors = author_repository.select_all()
    books = book_repository.select_all()
    return render_template("index.html", authors=authors, books=books)