if we do confuse the viewing / states AND we are in prod, then delete states and tell user to get a new tab / try again -- lame but it will work as a catch all

This commit is contained in:
2022-02-02 18:49:55 +11:00
parent e26a731883
commit b38e4fa0bb

View File

@@ -729,7 +729,12 @@ def view(id):
# face locn data, just warn & redirect # face locn data, just warn & redirect
if id not in eids: if id not in eids:
print( f"ERROR: viewing an id, but its not in eids OPT={OPT}, id={id}, eids={eids}") print( f"ERROR: viewing an id, but its not in eids OPT={OPT}, id={id}, eids={eids}")
st.SetMessage("Sorry, viewing data is confused, cannot view this image now", "warning" ) msg="Sorry, viewing data is confused, cannot view this image now"
if os.environ['FLASK_ENV'] == "production":
msg += "Clearing out all states. This means browser back buttons will not work, please start a new tab and try again"
PA_UserState.query.delete()
db.session.commit()
st.SetMessage( msg, "warning" )
return redirect("/") return redirect("/")
else: else:
return render_template("viewer.html", current=int(id), eids=eids, objs=objs, OPT=OPT ) return render_template("viewer.html", current=int(id), eids=eids, objs=objs, OPT=OPT )