adding extra debugs for weird bugs with losing data when viewing

This commit is contained in:
2024-04-07 20:18:40 +10:00
parent fed78672dc
commit 4885acea80
2 changed files with 13 additions and 0 deletions

View File

@@ -641,9 +641,12 @@ def view_list():
resp['last_eid']=OPT.last_eid
resp['eids']=eids
resp['offset']=OPT.offset
print( f"BUG-DEBUG: /view_list route #1 - OPT={OPT}, eids={eids} ")
# save pref to keep the new current value, first/last
pref=PA_UserState.query.filter(PA_UserState.pa_user_dn==current_user.dn,PA_UserState.orig_ptype==OPT.orig_ptype,PA_UserState.view_eid==OPT.view_eid).first()
print( f"BUG-DEBUG: /view_list route #2 - OPT={OPT}, eids={eids} ")
UpdatePref( pref, OPT )
print( f"BUG-DEBUG: /view_list route #3 - OPT={OPT}, eids={eids} ")
return make_response( resp )
@@ -691,6 +694,7 @@ def view(id):
imp_path = setting.import_path
st_path = setting.storage_path
bin_path = setting.recycle_bin_path
print( f"BUG-DEBUG: /view/id GET route - OPT={OPT}, eids={eids}, current={int(id)} ")
return render_template("viewer.html", current=int(id), eids=eids, objs=objs, OPT=OPT, NMO_data=NMO_data, imp_path=imp_path, st_path=st_path, bin_path=bin_path )
##################################################################################
@@ -701,6 +705,7 @@ def view(id):
def view_img_post(id):
# set pa_user_states...
OPT=States( request )
print( f"BUG-DEBUG: /view/id POST route - OPT={OPT}, id={id} ")
# then use back-button friendly URL (and use pa_user_states to view the right image in the right list
return redirect( "/view/" + id );

View File

@@ -59,6 +59,7 @@ class States(PA):
self.last_eid=0
self.num_entries=0
print("BUG-DEBUG: States() called view_eid reset to None")
# this is any next/prev or noo, grouping, etc. change (so use referrer to work out what to do with this)
# because this can happen on a view, or files_up, etc. change this FIRST
if 'change_file_opts' in request.path:
@@ -70,11 +71,13 @@ class States(PA):
if 'view_list' in request.path:
self.path_type = 'View'
self.view_eid = request.form['view_eid']
print(f"BUG-DEBUG: States() called view_eid set as 'view_list' in request.path - {self.view_eid}")
self.url = request.form['orig_url']
# this occurs ONLY when a POST to /view/<id> occurs (at this stage orig_url will be from an import, storage, bin or search)
elif 'view' in request.path:
self.path_type = 'View'
self.view_eid = self.url[6:]
print(f"BUG-DEBUG: States() called view_eid set as 'view' in request.path - {self.view_eid}")
# use orig url to define defaults/look up states for 'last' import/storage/bin/search
if request.method == "POST":
self.url = request.form['orig_url']
@@ -125,6 +128,8 @@ class States(PA):
elif 'view' in self.url:
# use url to get eid of viewed entry
self.view_eid = self.url[6:]
print(f"BUG-DEBUG: States() called 'view' in self.url view_eid={self.view_eid}")
# force this to be a search so rest of code won't totally die, but also not return anything
self.path_type="Search"
self.orig_url=self.url
@@ -163,6 +168,7 @@ class States(PA):
self.orig_search_term=pref.orig_search_term
self.orig_url = pref.orig_url
self.view_eid = pref.view_eid
print(f"BUG-DEBUG: view_eid based on prefs- {self.view_eid}")
self.current = pref.current
if self.path_type == "View":
self.root='static/' + self.orig_ptype
@@ -276,11 +282,13 @@ class States(PA):
noo=self.noo, grouping=self.grouping, how_many=self.how_many, st_offset=self.offset, size=self.size,
folders=self.folders, root=self.root, cwd=self.cwd, orig_ptype=self.orig_ptype, orig_search_term=self.orig_search_term,
orig_url=self.orig_url, current=self.current, first_eid=self.first_eid, last_eid=self.last_eid, num_entries=self.num_entries )
print( f"BUG-DEBUG: prefs SET based on self, view_eid={self.view_eid}")
else:
# update this pref with the values calculated above (most likely from POST to form)
pref.pa_user_dn=current_user.dn
pref.path_type=self.path_type
pref.view_eid=self.view_eid
print( f"BUG-DEBUG: prefs UPDATED based on self, view_eid={self.view_eid}")
pref.noo=self.noo
pref.grouping=self.grouping
pref.how_many=self.how_many