From 860a85e3ae2e9a9e94561bdcd3f06a8a4fa8f4dd Mon Sep 17 00:00:00 2001 From: Damien De Paoli Date: Thu, 7 Jan 2021 18:58:07 +1100 Subject: [PATCH] can now remove just 1 sub book - TODO-25 -- DONE --- README | 1 - main.py | 15 ++++++----- templates/book.html | 65 ++++++++++++++++++++++++++++++++++++--------- 3 files changed, 61 insertions(+), 20 deletions(-) diff --git a/README b/README index f84fa63..b25e836 100644 --- a/README +++ b/README @@ -28,7 +28,6 @@ python3 main.py #### 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 diff --git a/main.py b/main.py index 31485aa..dd79452 100644 --- a/main.py +++ b/main.py @@ -508,21 +508,24 @@ def book(id): if 'author-' in el: book.author.append( Author.query.get( request.form[el] ) ) + removing_series=[] + for field in request.form: + if 'removed-book_num' in field: + cnt=int(re.findall( '\d+', field )[0]) + removing_series.append( { 'series_id' : request.form['removed-series_id-{}'.format(cnt)] } ) still_in_series=0 - still_in_series_sid=99999 if book.IsParent(): for field in request.form: if 'bsl-book_num-' in field and field != 'bsl-book_num-NUM' and request.form[field] == 'PARENT': - cnt=int(re.findall( '\d+', field )[0]) - print("cnt={}".format(cnt)) - still_in_series_sid=request.form['bsl-series_id-{}'.format(cnt)] still_in_series=1 if book.IsChild() or (book.IsParent() and not still_in_series): + print ("okay should raise DBox") + print ("{}".format( removing_series )) if book.IsParent(): - CheckSeriesChange={'type':'parent', 'pid': book.id, 'bid': book.id} + CheckSeriesChange={'type':'parent', 'pid': book.id, 'bid': book.id, 'removing_series': removing_series } else: - CheckSeriesChange={'type':'child', 'pid': book.parent[0].id, 'bid': book.id } + CheckSeriesChange={'type':'child', 'pid': book.parent[0].id, 'bid': book.id, 'removing_series': removing_series } else: # delete all bsls db.engine.execute("delete from book_series_link where book_id = {}".format( book.id ) ) diff --git a/templates/book.html b/templates/book.html index 1f7d480..a02db01 100644 --- a/templates/book.html +++ b/templates/book.html @@ -22,13 +22,21 @@