first pass for series data, can save, and shows associated books... Does not deal with series inside series
This commit is contained in:
15
main.py
15
main.py
@@ -23,6 +23,7 @@ from covertype import Covertype, CovertypeForm, CovertypeSchema, GetCovertypeByI
|
||||
from owned import Owned, OwnedForm, OwnedSchema, GetOwnedById
|
||||
from rating import Rating, RatingForm, RatingSchema
|
||||
from loan import Loan, LoanForm, LoanSchema
|
||||
from series import Series, SeriesForm, SeriesSchema
|
||||
|
||||
# allow jinja2 to call this python function
|
||||
app.jinja_env.globals['GetCovertypeById'] = GetCovertypeById
|
||||
@@ -50,6 +51,11 @@ class Book_Loan_Link(db.Model):
|
||||
book_id = db.Column(db.Integer, db.ForeignKey('book.id'), unique=True, nullable=False, primary_key=True)
|
||||
loan_id = db.Column(db.Integer, db.ForeignKey('loan.id'), unique=True, nullable=False, primary_key=True)
|
||||
|
||||
class Book_Series_Link(db.Model):
|
||||
__tablename__ = "book_series_link"
|
||||
book_id = db.Column(db.Integer, db.ForeignKey('book.id'), unique=True, nullable=False, primary_key=True)
|
||||
series_id = db.Column(db.Integer, db.ForeignKey('series.id'), unique=True, nullable=False, primary_key=True)
|
||||
|
||||
class Book_Sub_Book_Link(db.Model):
|
||||
__tablename__ = "book_sub_book_link"
|
||||
book_id = db.Column(db.Integer, db.ForeignKey('book.id'), unique=True, nullable=False, primary_key=True)
|
||||
@@ -66,6 +72,7 @@ class Book(db.Model):
|
||||
publisher = db.relationship('Publisher', secondary=book_publisher_link)
|
||||
genre = db.relationship('Genre', secondary=book_genre_link )
|
||||
loan = db.relationship('Loan', secondary=Book_Loan_Link.__table__);
|
||||
series = db.relationship('Series', secondary=Book_Series_Link.__table__);
|
||||
year_published = db.Column(db.Integer)
|
||||
condition = db.Column(db.Integer, db.ForeignKey('condition.id'))
|
||||
covertype = db.Column(db.Integer, db.ForeignKey('covertype.id'))
|
||||
@@ -136,12 +143,14 @@ def books():
|
||||
|
||||
@app.route("/books_for_loan/<id>", methods=["GET"])
|
||||
def books_for_loan(id):
|
||||
# books = db.engine.execute ( "select * from book_loan_link where loan_id = {}".format( id ) )
|
||||
print( id )
|
||||
books = Book.query.join(Book_Loan_Link).filter(Book_Loan_Link.loan_id==id).order_by(Book.id).all()
|
||||
print( books )
|
||||
return render_template("books_for_loan.html", books=books)
|
||||
|
||||
@app.route("/books_for_series/<id>", methods=["GET"])
|
||||
def books_for_series(id):
|
||||
books = Book.query.join(Book_Series_Link).filter(Book_Series_Link.series_id==id).order_by(Book.id).all()
|
||||
return render_template("books_for_series.html", books=books)
|
||||
|
||||
@app.route("/book/<id>", methods=["GET"])
|
||||
def book(id):
|
||||
book = Book.query.get(id)
|
||||
|
||||
Reference in New Issue
Block a user