From 9560381a87ea096178f3a5d029bdb9163c29b64e Mon Sep 17 00:00:00 2001 From: Damien De Paoli Date: Thu, 7 Jan 2021 16:02:04 +1100 Subject: [PATCH] completed: TODO-22: adding a sub-book when the parent book is in a series, and renamed MAYBE-1 to TODO-23 (deal with moving book in a series with another series involved), 24 (dockerise), 25 (actually allow removing just one subbook form series) --- BUGs | 1 - README | 18 +++++++++--------- main.py | 6 ++++++ 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/BUGs b/BUGs index e83c9f8..aef1f3a 100644 --- a/BUGs +++ b/BUGs @@ -12,4 +12,3 @@ BUG-7: if you remove a series from a book, it won't appear in the series drop-d ### ordering of data in UI: BUG-6: author,series, etc. do not have explicit ordering like sub-books... sort of irritating / needs code and DB fix - add/remove authors, and after save they are ordered by author.id, not order of addition (prob. needs book_author_link to have an auth_num) - diff --git a/README b/README index d46b168..f84fa63 100644 --- a/README +++ b/README @@ -27,16 +27,14 @@ python3 main.py MUST use form.errors when we have a validator that is fancier than not empty (year_published in book and num_books in series SO FAR) -#### MAYBEs: -MAYBE-1: when moving a book in a series (which is part of 2 series), do we pop-up offer to move parent/child series orders as well to match (think Thomas Covenant) +#### TODOS (next 26): +TODO-25: allow removing of just this sub-book from a series -- can cause a need by messing with UI, so should just add it as a possible in the dialog box +TODO-23: when moving a book in a series (which is part of 2 series), do we pop-up offer to move parent/child series orders as well to match (think Thomas Covenant) +TODO-24: get this into docker (as per TODO above) + gunicorn and it seems easy enough: https://www.digitalocean.com/community/tutorials/how-to-serve-flask-applications-with-gunicorn-and-nginx-on-ubuntu-18-04 -#### TODOS (next 22): -TODO-5: should deleting really just ask if want to mark it as SOLD? IN FACT, make delete button disabled until its sold... (and a tooltip to explain) -TODO-22: adding a sub-book when the parent book is in a series, need to add bsl(s) for it and make it the next (probably) -TODO-21: allow a way to add a book as a child of another existing book (opposite of rem_sub_book) - -TODO-8: show books on shelf list -TODO-9: show books to buy view / printable +TODO-08: show books on shelf list +TODO-09: show books to buy view / printable TODO-11: show unrated books (with toggle to exclude those with missing in a series) TODO-12: show books missing from a series (I own only some of them) TODO-13: show books on wish list @@ -51,5 +49,7 @@ TODO-19: icons on wish list, etc.? (not sure I really want them, but if so) - wishlist: search-dollar OR https://www.flaticon.com/free-icon/wishlist_868517 - save: https://www.flaticon.com/free-icon/sold_463255?term=sold&page=1&position=6&related_item_id=463255 +TODO-05: should deleting really just ask if want to mark it as SOLD? IN FACT, make delete button disabled until its sold... (and a tooltip to explain) TODO-20: ORM all books load is slow - should I lazy load all books (ajax the 2nd->last pages in, or not use ORM, and do a quick db.execute()....) +TODO-21: allow a way to add a book as a child of another existing book (opposite of rem_sub_book) diff --git a/main.py b/main.py index e52e134..31485aa 100644 --- a/main.py +++ b/main.py @@ -410,6 +410,12 @@ def new_book(): db.session.commit() if 'parent_id' in request.form: db.engine.execute( "insert into book_sub_book_link ( book_id, sub_book_id, sub_book_num ) values ( {}, {}, (select COALESCE(MAX(sub_book_num),0)+1 from book_sub_book_link where book_id = {}) )".format( request.form['parent_id'], book.id, request.form['parent_id'] ) ) + parent=Book.query.get(request.form['parent_id']) + print( parent.series ) + if len(parent.series) > 0: + print ("I think this means we have added a sub-book to something in a series already" ) + for s in parent.bsl: + db.engine.execute( "insert into book_series_link ( series_id, book_id, book_num ) values ( {}, {}, {} )".format( s.series_id, book.id, (s.book_num+1) ) ) db.session.commit() st.SetMessage( "Created new Book ({})".format(book.title) ) cnt=1