fixed BUG-74 and 79 with new States model

This commit is contained in:
2022-01-20 17:37:37 +11:00
parent 78acb9bd66
commit 9ca24358d0
3 changed files with 9 additions and 6 deletions

6
BUGs
View File

@@ -1,10 +1,8 @@
### Next: 81
BUG-56: when making a viewing list of AI:mich, (any search?) and going past the page_size, it gets the wrong data from the DB for the 'next' entry
BUG-60: entries per page (in folders view) ignores pagesize, and this also contributes to BUG-56 I think
BUG-74: search/others? remembers start/offset, and if you reset view (e.g. another search) it doesnt show first page of results
BUG-56: when making a viewing list of AI:mich, (any search?) and going past the page_size, it dies
BUG-60: entries per page (in folders view) ignores pagesize / does not count Dirs?, and this also contributes to BUG-56 I think
BUG-77: when moving folders out from a parent folder (storage/2020 off-camera-to-oct), it did not delete the empty 2020 off-camera-to-oct folder
-- something odd happened here, not sure it is a bug, maybe dodgy data at the time in the DB?
BUG-79: changing size does not post back the OPT change, so doesn't save to prefs (unless you change say how_many after size)
BUG-80: viewed AI:fikkers, and next, next, etc. got this:
ESC[36mpaweb |ESC[0m [2022-01-16 01:19:34,305] ERROR in app: Exception on /viewlist [POST]
ESC[36mpaweb |ESC[0m Traceback (most recent call last):

View File

@@ -371,10 +371,13 @@ def files_rbp():
# be used even if the user hits the front/back buttons in the browser.
# func shows thumbnails of matching files.
################################################################################
@app.route("/search/<search_term>", methods=["GET"])
@app.route("/search/<search_term>", methods=["GET", "POST"])
@login_required
def search(search_term):
OPT=States( request )
# if we posted to get here, its a change in State, so save it to pa_user_state, and go back to the GET version or URL
if request.method=="POST":
redirect("/search/"+search_term)
OPT.search_term = search_term
# always show flat results for search to start with
OPT.folders=False

View File

@@ -89,6 +89,8 @@ class States(PA):
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()
elif self.path_type == 'Search':
pref=PA_UserState.query.filter(PA_UserState.pa_user_dn==current_user.dn,PA_UserState.path_type==self.path_type,PA_UserState.orig_search_term==self.orig_search_term).first()
else:
pref=PA_UserState.query.filter(PA_UserState.pa_user_dn==current_user.dn,PA_UserState.path_type==self.path_type).first()
@@ -160,7 +162,7 @@ class States(PA):
# now save pref
if not pref:
# if there is an PA_UserState( pa_user_dn=current_user.dn, # path_type=self.path_type ), then its for a different view_eid and we are viewing, delete it before we insert the new
# 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 )