From 2e4b1ed9d2bb3052e3e4ba9f1c53d691aeab7637 Mon Sep 17 00:00:00 2001 From: Damien De Paoli Date: Sat, 22 Jan 2022 23:26:14 +1100 Subject: [PATCH] defaults in PAuser include noo/folders for import/storage separated, defaults are stored into PAUser in DB, changable in GUI, used as the defaults for new PA_User_States. Also disabled search noo, search folders as they are hard-coded in the ORM retreive anyway --- BUGs | 2 ++ TODO | 9 +++++---- main.py | 2 +- states.py | 45 +++++++++++++++++++++++-------------------- tables.sql | 6 ++++-- templates/files.html | 4 ++++ templates/states.html | 32 ++++++++++++++++++++---------- user.py | 20 ++++++++++++------- 8 files changed, 75 insertions(+), 45 deletions(-) diff --git a/BUGs b/BUGs index 45f0dd2..b13a345 100644 --- a/BUGs +++ b/BUGs @@ -1,3 +1,5 @@ ### Next: 81 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 flat view will get how_many from each top-level dir in PATH (not a big issue, but it is a little misleading) +BUg-81: search for AI:mich, she is matched twice in a montage image, and so 2 faces, 1 file -- means the next button is disabled as it uses basic logic of # of photos to display < how_many (so get 10 matches from DB, but only show 9 files with how_many 10) -- next is then disabled + - could get actual last (and first) eid and store it in pa_user_state diff --git a/TODO b/TODO index 17ffa46..1557100 100644 --- a/TODO +++ b/TODO @@ -1,10 +1,7 @@ ## GENERAL * for below.. make Options( request ) - remove all "Options()" that are not set by a user-choice in the F/E and just make sure new "Options" sets all defaults as needed - - in fact if we "re-use" a pa_user_state, we need to update it with anything that changed -- not sure but that should just happen in State() - - use prefs in States() for defaults, rather than hardcoding "50", etc. - - search allows folder/flat change in GUI, should disable it - - search NOO -- no code to handle noo!!! + - some done, just finish it * going forward into search page (and probably all POSTs) does not work -- use POST -> redirect to GET /viewlist ? -> think it works, BUT, need a rewrite anyway to use json data rather than new urls... @@ -14,6 +11,10 @@ files.py:@app.route("/fix_dups", methods=["POST"]) ??? + * delete / rescan in dev, needs to delete faces, frl, ffl, ... + + * search allow noo? + * optim to not run_ai_on_* for scan, needs to make sure last run_ai_on actually ran/worked - might have failed (or in my case was marked stale and I cancelled it) -- also the case for get file details though, need to make sure last one was completed diff --git a/main.py b/main.py index 94ecb03..be1726c 100644 --- a/main.py +++ b/main.py @@ -92,7 +92,7 @@ def save_user(dn, username, data, memberships): # if we already have a valid user/session, and say the web has restarted, just re-use it, dont make more users if pau: return pau - pau=PAUser(dn=dn, default_noo="Oldest", default_grouping="None", default_how_many=50, default_size=128, default_folders=True, default_fullscreen=False) + pau=PAUser(dn=dn, default_import_noo="Oldest", default_storage_noo="A to Z", default_grouping="None", default_how_many=50, default_size=128, default_import_folders=False, default_storage_folders=True, default_fullscreen=False) db.session.add(pau) db.session.commit() return pau diff --git a/states.py b/states.py index 27e7c29..6783aa9 100644 --- a/states.py +++ b/states.py @@ -56,15 +56,12 @@ class States(PA): base=request.base_url base=base.replace("ChangeFileOpts", "") self.url = "/"+ref.replace(base, "" ) - print( f"started with ChangeFileOpts, so self.url now is {self.url}, bu={request.base_url}") # if viewlist, then we really are a view, and view_eid should be in the form if 'viewlist' in request.path: self.path_type = 'View' self.view_eid = request.form['view_eid'] self.url = request.form['orig_url'] - for el in request.form: - print( f"{el}={request.form[el]}" ) # this occurs ONLY when a POST to /view/ occurs (at this stage orig_url will be from an import, storage, bin or search) elif 'view' in request.path: self.path_type = 'View' @@ -77,7 +74,6 @@ class States(PA): # 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() self.url = pref.orig_url - print( f"view/ so change url to: '{self.url}'" ) print( f"NOW, url={self.url}" ) @@ -103,7 +99,6 @@ class States(PA): # okay if we are a search, but came from a view then get last_search_state form prefs and use it self.orig_search_term = self.url[8:] if self.path_type == "View": - print(f"view, url={self.url}") self.orig_ptype = 'Search' self.orig_url = self.url else: @@ -113,21 +108,13 @@ class States(PA): self.view_eid = self.url[6:] self.path_type="View" self.orig_url=self.url - print( f"in view, eid={self.view_eid}, orig_url={self.orig_url}" ) - elif 'ChangeFileOpts' in self.url: - print( f"ChangeFileOpts called, so all good?" ) - else: - print( f"referrer={request.referrer}" ) + elif 'ChangeFileOpts' not in self.url: print( f"ERROR: DDP messed up, failed to match URL {self.url} for settings this will fail, redirecting to home" ) + print( f"referrer={request.referrer}" ) return if self.path_type == 'View': - print( f"its is a view, find the pref: {self.view_eid}" ) 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() - if not pref: - print( f"no pref" ) - else: - print( f"pref={pref}" ) 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: @@ -147,16 +134,30 @@ class States(PA): self.orig_url = pref.orig_url self.view_eid = pref.view_eid else: - self.folders=False - self.noo="Oldest" - self.grouping="None" - self.how_many="50" + # retreive defaults from 'PAUser' where defaults are stored + u=PAUser.query.filter(PAUser.dn==current_user.dn).one() + self.grouping=u.default_grouping + self.how_many=u.default_how_many self.offset="0" - self.size="128" + self.size=u.default_size if self.path_type == "View": self.root='static/' + self.orig_ptype + tmp=self.orig_ptype else: self.root='static/' + self.path_type + tmp=self.path_type + if tmp == 'Import': + self.noo = u.default_import_noo + self.folders = u.default_import_folders + elif tmp == 'Storage': + self.noo = u.default_storage_noo + self.folders = u.default_storage_folders + else: + # is a search so... + print( "For now, search defaults for noo / folders are hardcoded" ) + self.folders=False + self.noo = 'Oldest' + self.cwd=self.root if not hasattr(self, 'orig_ptype'): self.orig_ptype=None @@ -206,12 +207,14 @@ class States(PA): if 'next' in request.form: self.offset += int(self.how_many) - # 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. + # now save pref if not pref: + # insert new pref for this combo (might be a new search or view, or first time for a path) 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, orig_url=self.orig_url ) 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 diff --git a/tables.sql b/tables.sql index df3fd34..3e67014 100644 --- a/tables.sql +++ b/tables.sql @@ -18,11 +18,13 @@ create table SETTINGS( create table PA_USER( ID integer, DN varchar unique, - DEFAULT_NOO varchar, + DEFAULT_IMPORT_NOO varchar, + DEFAULT_STORAGE_NOO varchar, DEFAULT_GROUPING varchar(16), DEFAULT_HOW_MANY integer, DEFAULT_SIZE integer, - DEFAULT_FOLDERS Boolean, + DEFAULT_IMPORT_FOLDERS Boolean, + DEFAULT_STORAGE_FOLDERS Boolean, DEFAULT_FULLSCREEN Boolean, constraint PK_PA_USER_ID primary key(ID) ); diff --git a/templates/files.html b/templates/files.html index db017aa..058cd05 100644 --- a/templates/files.html +++ b/templates/files.html @@ -56,6 +56,10 @@
Searched for: '{{search_term}}'
+ {% endif %}