fix up issue with various fields for a View using last View values, rather than orig_ptype values -- which can now change as we change noo/folders

This commit is contained in:
2022-01-29 18:54:31 +11:00
parent 7a17d91779
commit cce78b019c

View File

@@ -80,8 +80,7 @@ class States(PA):
if request.method == "POST": if request.method == "POST":
self.url = request.form['orig_url'] self.url = request.form['orig_url']
else: else:
# GET's occur on redirect, and we don't have a form, so get it # GET's occur on redirect, and we don't have a form, so get it from pref
# 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() 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()
self.url = pref.orig_url self.url = pref.orig_url
@@ -131,22 +130,30 @@ class States(PA):
pref=PA_UserState.query.filter(PA_UserState.pa_user_dn==current_user.dn,PA_UserState.path_type==self.path_type).first() pref=PA_UserState.query.filter(PA_UserState.pa_user_dn==current_user.dn,PA_UserState.path_type==self.path_type).first()
if pref: if pref:
self.folders=pref.folders
self.noo=pref.noo
self.grouping=pref.grouping self.grouping=pref.grouping
self.how_many=pref.how_many self.how_many=pref.how_many
self.offset=pref.st_offset self.offset=pref.st_offset
self.size=pref.size self.size=pref.size
self.root=pref.root
self.cwd=pref.cwd self.cwd=pref.cwd
self.orig_ptype=pref.orig_ptype self.orig_ptype=pref.orig_ptype
self.orig_search_term=pref.orig_search_term self.orig_search_term=pref.orig_search_term
self.orig_url = pref.orig_url self.orig_url = pref.orig_url
self.view_eid = pref.view_eid self.view_eid = pref.view_eid
self.current = pref.current self.current = pref.current
if self.path_type == "View":
self.root='static/' + self.orig_ptype
self.first_eid=orig_pref.first_eid
self.last_eid=orig_pref.last_eid
self.num_entries=orig_pref.num_entries
self.noo=orig_pref.noo
self.folders=orig_pref.folders
else:
self.root=pref.root
self.first_eid = pref.first_eid self.first_eid = pref.first_eid
self.last_eid = pref.last_eid self.last_eid = pref.last_eid
self.num_entries = pref.num_entries self.num_entries = pref.num_entries
self.noo=pref.noo
self.folders=pref.folders
else: else:
# retreive defaults from 'PAUser' where defaults are stored # retreive defaults from 'PAUser' where defaults are stored
u=PAUser.query.filter(PAUser.dn==current_user.dn).one() u=PAUser.query.filter(PAUser.dn==current_user.dn).one()
@@ -185,7 +192,12 @@ class States(PA):
# the above are defaults, if we are here, then we have current values, use them instead if they are set -- AI: searches dont set them so then we use those in the DB first # the above are defaults, if we are here, then we have current values, use them instead if they are set -- AI: searches dont set them so then we use those in the DB first
if request.method=="POST": if request.method=="POST":
if self.path_type != "View" and 'noo' in request.form: if self.path_type != "View" and 'noo' in request.form:
# we are changing values based on a POST to the form, if we changed the noo option, we need to reset things
if 'ChangeFileOpts' in request.path and self.noo != request.form['noo']:
self.noo=request.form['noo'] self.noo=request.form['noo']
self.first_eid=0
self.last_eid=0
self.offset=0
if 'how_many' in request.form: if 'how_many' in request.form:
self.how_many=request.form['how_many'] self.how_many=request.form['how_many']
if 'offset' in request.form: if 'offset' in request.form:
@@ -197,13 +209,17 @@ class States(PA):
self.size = request.form['size'] self.size = request.form['size']
# seems html cant do boolean, but uses strings so convert # seems html cant do boolean, but uses strings so convert
if self.path_type != "View" and 'folders' in request.form: if self.path_type != "View" and 'folders' in request.form:
# we are changing values based on a POST to the form, if we changed the folders option, we need to reset things
if 'ChangeFileOpts' in request.path and self.folders != request.form['folders']:
self.num_entries=0
self.first_eid=0
self.last_eid=0
if request.form['folders'] == "False": if request.form['folders'] == "False":
self.folders=False self.folders=False
else: else:
self.folders=True self.folders=True
# have to force grouping to None if we flick to folders from a flat # have to force grouping to None if we flick to folders from a flat view with grouping (otherwise we print out
# view with grouping (otherwise we print out group headings for # group headings for child content that is not in the CWD)
# child content that is not in the CWD)
self.grouping=None self.grouping=None
if 'orig_url' in request.form: if 'orig_url' in request.form:
self.orig_url = request.form['orig_url'] self.orig_url = request.form['orig_url']
@@ -254,10 +270,11 @@ class States(PA):
pref.orig_search_term = self.orig_search_term pref.orig_search_term = self.orig_search_term
pref.orig_url = self.orig_url pref.orig_url = self.orig_url
pref.last_used = last_used pref.last_used = last_used
pref.first_eid = self.first_eid
pref.last_eid = self.last_eid
pref.num_entries = self.num_entries
# only passed in (at the moment) in viewlist # only passed in (at the moment) in viewlist
pref.current = self.current pref.current = self.current
# first_eid, last_eid, num_entries wont change in this func, set only in GetEntries()
db.session.add(pref) db.session.add(pref)
db.session.commit() db.session.commit()