first pass of the data required for editing a single book
This commit is contained in:
3
README
3
README
@@ -16,6 +16,7 @@ python3 main.py
|
||||
|
||||
|
||||
### TODO:
|
||||
- book subbook link will be next real challenge
|
||||
- book subbook link will be next real challenge (with raw sql for now)
|
||||
- then next challenge will be to make single book page an edit / save
|
||||
- then its just finish this off :)
|
||||
- fix up lame book linkages to tabels that are so not 3nf, *_LST tables, etc.
|
||||
|
||||
11
main.py
11
main.py
@@ -106,10 +106,17 @@ def book(id):
|
||||
book_s = book_schema.dump(book)
|
||||
|
||||
# force sub books for jinja2 to be able to use
|
||||
subs = db.engine.execute ( "select book_id, sub_book_id, sub_book_num from book_sub_book_link where book_id = " + id )
|
||||
subs = db.engine.execute ( "select bsb.book_id, bsb.sub_book_id, bsb.sub_book_num, book.title, book.rating, book.year_published, book.notes, bal.author_id as author_id, author.surname||', '||author.firstnames as author from book_sub_book_link bsb, book, book_author_link bal, author where bsb.book_id = {} and book.id = bsb.sub_book_id and book.id = bal.book_id and bal.author_id = author.id".format( id ) )
|
||||
sub_book=[]
|
||||
for row in subs:
|
||||
sub_book.append( { 'sub_book_id': row.sub_book_id, 'sub_book_num': row.sub_book_num } )
|
||||
# get genres for sub book and add by hand first
|
||||
tmp_g = []
|
||||
genres = db.engine.execute ( "select genre_lst.id, genre_lst.genre from genre_lst, book_genre_link bgl where genre_lst.id = bgl.genre_id and bgl.book_id = {}".format( row.sub_book_id ) )
|
||||
for genre in genres:
|
||||
tmp_g.append( { 'id': genre.id, 'genre': genre.genre } )
|
||||
|
||||
sub_book.append( { 'sub_book_id': row.sub_book_id, 'sub_book_num': row.sub_book_num, 'title' : row.title, 'rating': row.rating, 'year_published' : row.year_published, 'notes' : row.notes, 'author_id' : row.author_id, 'author' : row.author, 'genres' : tmp_g } )
|
||||
|
||||
book_s['sub_book'] = sub_book
|
||||
print( book_s )
|
||||
|
||||
|
||||
Reference in New Issue
Block a user