fixed BUG-26 (saving with a series), and added a bookdb_webdev container that maps ~/src/pybook to /pybook_mapped_volume. Then start a single threaded, reloading, output capturing gunicorn via wraper.sh if in DEV, otherwise normal gunicorn if in PROD - gives me an idnentical dev in a container to prod.
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,3 +1,4 @@
|
||||
__pycache__/
|
||||
DB_BACKUP/
|
||||
static/
|
||||
gunicorn.*
|
||||
|
||||
20
main.py
20
main.py
@@ -21,6 +21,8 @@ app = Flask(__name__)
|
||||
# local DB conn string
|
||||
if os.environ['FLASK_ENV'] == "production":
|
||||
DB_URL = 'postgresql+psycopg2://ddp:blahdeblah@bookdb:5432/library'
|
||||
elif os.environ['FLASK_ENV'] == "development":
|
||||
DB_URL = 'postgresql+psycopg2://ddp:blahdeblah@bookdb_dev:5432/library'
|
||||
else:
|
||||
DB_URL = 'postgresql+psycopg2://ddp:blahdeblah@127.0.0.1:55432/library'
|
||||
|
||||
@@ -680,29 +682,27 @@ def book(id):
|
||||
child_book.blurb=book.blurb
|
||||
|
||||
# if removing_series has something in it, then handle it
|
||||
if (len(removing_series) > 0) and (book.IsChild() or (book.IsParent() and not still_in_series)):
|
||||
print ("okay should raise DBox")
|
||||
print ("{}".format( removing_series ))
|
||||
print (f"still_in_series={still_in_series}" )
|
||||
if book.IsChild() or (book.IsParent() and not still_in_series):
|
||||
if book.IsParent():
|
||||
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, 'removing_series': removing_series }
|
||||
else:
|
||||
# delete all bsls
|
||||
with db.engine.connect() as conn:
|
||||
conn.exec_driver_sql( "delete from book_series_link where book_id = {}".format( book.id ) )
|
||||
Book_Series_Link.query.filter(Book_Series_Link.book_id == book.id ).delete()
|
||||
|
||||
cnt=1
|
||||
for field in request.form:
|
||||
if 'bsl-book_id-' in field and field != 'bsl-book_id-NUM':
|
||||
cnt=int(re.findall( '\d+', field )[0])
|
||||
if book.IsParent():
|
||||
sql="insert into book_series_link (book_id, series_id) values ( {}, {} )".format( request.form['bsl-book_id-{}'.format(cnt)], request.form['bsl-series_id-{}'.format(cnt)] )
|
||||
newbsl=Book_Series_Link( book_id=request.form[f'bsl-book_id-{cnt}'],
|
||||
series_id=request.form[f'bsl-series_id-{cnt}'] )
|
||||
else:
|
||||
sql="insert into book_series_link (book_id, series_id, book_num) values ( {}, {}, {} )".format( request.form['bsl-book_id-{}'.format(cnt)], request.form['bsl-series_id-{}'.format(cnt)], request.form['bsl-book_num-{}'.format(cnt)])
|
||||
with db.engine.connect() as conn:
|
||||
conn.exec_driver_sql( sql )
|
||||
newbsl=Book_Series_Link( book_id=request.form[f'bsl-book_id-{cnt}'],
|
||||
series_id=request.form[f'bsl-series_id-{cnt}'],
|
||||
book_num=request.form[f'bsl-book_num-{cnt}'] )
|
||||
db.session.add(newbsl)
|
||||
db.session.commit()
|
||||
# reset rating on this series as the book has changed (and maybe the rating has changed)
|
||||
for field in request.form:
|
||||
|
||||
Reference in New Issue
Block a user