viewing same eid but different search, etc. caused BUG-84 -- Fixed now as we look for a pa_user_state of View, eid=<eid>, orig_search_term=<...>

This commit is contained in:
2022-02-02 18:51:02 +11:00
parent 3d829a6118
commit a830e8dc92

View File

@@ -6,6 +6,7 @@ from shared import PA
from user import PAUser
from datetime import datetime
import pytz
import re
################################################################################
# PA_UserState: preference data for a given user / path_type combo, so a given user
@@ -80,7 +81,10 @@ class States(PA):
self.url = request.form['orig_url']
else:
# GET's occur on redirect, and we don't have a form, so get it from pref
pref=PA_UserState.query.filter(PA_UserState.pa_user_dn==current_user.dn,PA_UserState.path_type==self.path_type,PA_UserState.view_eid==self.view_eid).first()
st=self.url[8:]
ref=request.referrer
st=re.sub( '.+/search/', '', ref )
pref=PA_UserState.query.filter(PA_UserState.pa_user_dn==current_user.dn,PA_UserState.path_type==self.path_type,PA_UserState.view_eid==self.view_eid,PA_UserState.orig_search_term==st).first()
self.url = pref.orig_url
if 'files_ip' in self.url or 'file_list_ip' in self.url:
@@ -120,7 +124,7 @@ class States(PA):
return
if self.path_type == 'View':
pref=PA_UserState.query.filter(PA_UserState.pa_user_dn==current_user.dn,PA_UserState.path_type==self.path_type,PA_UserState.view_eid==self.view_eid).first()
pref=PA_UserState.query.filter(PA_UserState.pa_user_dn==current_user.dn,PA_UserState.path_type==self.path_type,PA_UserState.view_eid==self.view_eid,PA_UserState.orig_search_term==self.orig_search_term).first()
# should find original path or search for this view (if not a search, search_term='')
orig_pref=PA_UserState.query.filter(PA_UserState.pa_user_dn==current_user.dn,PA_UserState.path_type==self.orig_ptype,PA_UserState.orig_search_term==self.orig_search_term).first()
elif self.path_type == 'Search':
@@ -146,6 +150,7 @@ class States(PA):
self.num_entries=orig_pref.num_entries
self.noo=orig_pref.noo
self.folders=orig_pref.folders
self.orig_search_term=orig_pref.orig_search_term
else:
self.root=pref.root
self.first_eid = pref.first_eid
@@ -167,6 +172,7 @@ class States(PA):
self.num_entries=orig_pref.num_entries
self.noo=orig_pref.noo
self.folders=orig_pref.folders
self.orig_search_term=orig_pref.orig_search_term
else:
self.root='static/' + self.path_type
if self.path_type == 'Import':
@@ -235,6 +241,7 @@ class States(PA):
if (self.offset + int(self.how_many)) < self.num_entries:
self.offset += int(self.how_many)
else:
# should be impossible now, but leave jic
print( f"WARNING: next image requested, but would go past end of list? - ignore this" )
print( f"DDP - offset={self.offset} + how_many={self.how_many} > num_entries={self.num_entries}" )
if 'current' in request.form: