fixed BUG-11, parent was both an array (in Book) and not an array in QuickBook, so made them arrays to keep with ORM-way
This commit is contained in:
25
main.py
25
main.py
@@ -31,6 +31,13 @@ from loan import Loan, LoanForm, LoanSchema
|
||||
from series import Series, SeriesForm, SeriesSchema, ListOfSeriesWithMissingBooks
|
||||
|
||||
####################################### CLASSES / DB model #######################################
|
||||
class QuickParentBook:
|
||||
parent=[]
|
||||
|
||||
def __repr__(self):
|
||||
return "<parent: {}, publisher: {}, owned: {}, covertype: {}, condition: {}, blurb: {}>".format(self.parent, self.publisher, self.owned, self.covertype, self.condition, self.blurb )
|
||||
|
||||
|
||||
book_author_link = db.Table('book_author_link', db.Model.metadata,
|
||||
db.Column('book_id', db.Integer, db.ForeignKey('book.id')),
|
||||
db.Column('author_id', db.Integer, db.ForeignKey('author.id'))
|
||||
@@ -178,7 +185,7 @@ class BookForm(FlaskForm):
|
||||
submit = SubmitField('Save' )
|
||||
delete = SubmitField('Delete' )
|
||||
add_sub = SubmitField('Add Sub-Book' )
|
||||
|
||||
rem_sub = SubmitField('Remove Sub-Book from Parent' )
|
||||
|
||||
################################# helper functions ###################################
|
||||
def GetBookIdFromSeriesByBookNum( series_id, book_num ):
|
||||
@@ -339,12 +346,13 @@ def subbooks_for_book(id):
|
||||
|
||||
return render_template("subbooks_for_book.html", sub_books=sub_book, s2=subs )
|
||||
|
||||
class QuickParentBook:
|
||||
parent=[]
|
||||
|
||||
def __repr__(self):
|
||||
return "<parent: {}, publisher: {}, owned: {}, covertype: {}, condition: {}, blurb: {}>".format(self.parent, self.publisher, self.owned, self.covertype, self.condition, self.blurb )
|
||||
|
||||
################################################################################
|
||||
# /remove_sub_book -> POST -> removes this subbook from parent
|
||||
# /books (or /book/<parent_id> -- if you added a sub-book of parent_id
|
||||
################################################################################
|
||||
@app.route("/remove_subbook", methods=["POST"])
|
||||
def remove_sub_book():
|
||||
return redirect( '/book/{}'.format(request.form['rem_sub_parent_id']) )
|
||||
|
||||
################################################################################
|
||||
# /book -> GET/POST -> creates a new book and when created, takes you back to
|
||||
@@ -369,7 +377,7 @@ def new_book():
|
||||
parent=request.form['add_sub_parent_id']
|
||||
book = Book.query.get(parent)
|
||||
bb=QuickParentBook()
|
||||
bb.parent= { 'id': parent, 'title': book.title }
|
||||
bb.parent.append( { 'id': parent, 'title': book.title } )
|
||||
form.publisher.default = book.publisher
|
||||
form.owned.default = book.owned
|
||||
form.condition.default = book.condition
|
||||
@@ -499,6 +507,7 @@ def book(id):
|
||||
genre_list = GetGenres()
|
||||
|
||||
book_s = book_schema.dump(book)
|
||||
print( book.parent )
|
||||
return render_template("book.html", b=book, books=book_s, book_form=book_form, author_list=author_list, genre_list=genre_list, page_title=page_title, alert=st.GetAlert(), message=st.GetMessage(), poss_series_list=ListOfSeriesWithMissingBooks() )
|
||||
|
||||
def GetCount( what, where ):
|
||||
|
||||
Reference in New Issue
Block a user