Make scrolling message conditionally include information.
This fixes a number of Nonetype accessing bugs when things are not present in the database. Have manually tested this for now.
This commit is contained in:
parent
d99ca13ab4
commit
0157faa8db
@ -157,20 +157,33 @@ def uploaded_file_cover(filename):
|
|||||||
|
|
||||||
@app.route('/updates', methods=['POST', 'GET'])
|
@app.route('/updates', methods=['POST', 'GET'])
|
||||||
def get_updates():
|
def get_updates():
|
||||||
userin = UserIns.query.filter_by(title="lastViewed").first()
|
|
||||||
allbooks = db.session.query(Book).all()
|
allbooks = db.session.query(Book).all()
|
||||||
latest_upload = allbooks[-1]
|
|
||||||
return (
|
scrolling_message = (
|
||||||
"This is the XPPL ~ Library XPUB ~ Updates / / / / / / / Last viewed: "
|
'{domain} ~ XPPL ~ Updates'
|
||||||
+ userin.info
|
' / / / / / / / '
|
||||||
+ " / / / / / / / "
|
'{count} books online '
|
||||||
+ str(len(allbooks))
|
).format(
|
||||||
+ " Books online "
|
domain=app.config['DOMAIN'],
|
||||||
+ " / / / / / / / "
|
count=str(len(allbooks))
|
||||||
+ "Latest entry: "
|
|
||||||
+ latest_upload.title
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
userin = UserIns.query.filter_by(title='lastViewed').first()
|
||||||
|
if userin:
|
||||||
|
scrolling_message += (
|
||||||
|
' / / / / / / / '
|
||||||
|
' Last viewed: {user}'
|
||||||
|
).format(user=userin.info)
|
||||||
|
|
||||||
|
if allbooks:
|
||||||
|
latest_upload = allbooks[-1]
|
||||||
|
scrolling_message += (
|
||||||
|
' / / / / / / / '
|
||||||
|
'Latest entry: {title}'
|
||||||
|
).format(title=latest_upload.title)
|
||||||
|
|
||||||
|
return scrolling_message
|
||||||
|
|
||||||
|
|
||||||
@app.route('/volumetric_catalog', methods=['GET'])
|
@app.route('/volumetric_catalog', methods=['GET'])
|
||||||
def volumetric_catalog():
|
def volumetric_catalog():
|
||||||
|
Loading…
Reference in New Issue
Block a user