clean up of states, to support multiple searches/views, and this will at least work for back/forward in prod - I believe. Still needs defaults from prefs, AND, remove unneeded variables from template/* and set those default values based on prefs

This commit is contained in:
2022-01-21 16:48:05 +11:00
parent a856bcd6b2
commit b58afa3a5c
4 changed files with 25 additions and 8 deletions

View File

@@ -12,6 +12,7 @@ from shared import PA
################################################################################
class PA_UserState(db.Model):
__tablename__ = "pa_user_state"
id = db.Column(db.Integer, db.Sequence('pa_user_state_id_seq'), primary_key=True )
pa_user_dn = db.Column(db.String, db.ForeignKey('pa_user.dn'), primary_key=True )
path_type = db.Column(db.String, primary_key=True, unique=False, nullable=False )
noo = db.Column(db.String, unique=False, nullable=False )
@@ -23,7 +24,7 @@ class PA_UserState(db.Model):
fullscreen = db.Column(db.Boolean, unique=False, nullable=False )
root = db.Column(db.String, unique=False, nullable=False )
cwd = db.Column(db.String, unique=False, nullable=False )
## this is non normal form, but this table only ever has a handful of rows per user, not worth the extra effort
## for now being lazy and not doing a separate table until I settle on needed fields and when
# only used if ptype == View
view_eid = db.Column(db.Integer, unique=False, nullable=False )
orig_ptype = db.Column(db.String, unique=False, nullable=False )
@@ -160,10 +161,8 @@ class States(PA):
if 'next' in request.form:
self.offset += int(self.how_many)
# now save pref
# now save pref (if this is 'another' search, view, etc. then it will add a row for it with matching search_term, or view_eid, etc.
if not pref:
# now we have 'unique' search and view states, blow away any old ones that are not this unique combo (different search term, or different image viewed)
old_pref=PA_UserState.query.filter(PA_UserState.pa_user_dn==current_user.dn,PA_UserState.path_type==self.path_type).delete()
pref=PA_UserState( pa_user_dn=current_user.dn, path_type=self.path_type, view_eid=self.view_eid, 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 )
else: