From 24c3762c614066a5a08a7aa22e27866ad3f7f25d Mon Sep 17 00:00:00 2001 From: Damien De Paoli Date: Sun, 5 Oct 2025 22:19:58 +1100 Subject: [PATCH] remove PathDetails*, and use marshmallow schemas with methods to get icon_url, and "path" renamed to "root_dir", updated move* code to use new data structure --- internal/js/files_support.js | 6 ++--- path.py | 50 ------------------------------------ 2 files changed, 3 insertions(+), 53 deletions(-) diff --git a/internal/js/files_support.js b/internal/js/files_support.js index e40a4c1..5fb994a 100644 --- a/internal/js/files_support.js +++ b/internal/js/files_support.js @@ -119,12 +119,12 @@ function MoveDBox(path_details, db_url)
' + div += ' value="' + path_details[0].type.name + '">' div+=GetSelnAsDiv() yr=$('.highlight').first().attr('yr') dt=$('.highlight').first().attr('date') div+='
Use Existing Directory (in the chosen path):
' - GetExistingDirsAsDiv( dt, "existing", path_details[0].type ) + GetExistingDirsAsDiv( dt, "existing", path_details[0].type.name ) div+=`
@@ -133,7 +133,7 @@ function MoveDBox(path_details, db_url) div+= '' div+= '' div+=` diff --git a/path.py b/path.py index f3834d2..503f7e9 100644 --- a/path.py +++ b/path.py @@ -42,53 +42,3 @@ class Path(db.Model): def __repr__(self): return f"" - - -################################################################################ -# Class describing PathDetail (quick connvenence class for MovePathDetails()) -################################################################################ -class PathDetail(PA): - """Class describing details of a Path [internal class used in MovePathDetais()]""" - - def __init__(self,ptype,path): - """Initialisation function for PathDetail class - - Args: - id (int): database id of row in PathDetail table / primary key - ptype (int): database id of row in PathType table / foreign key - """ - - self.type:int=ptype - self.path:str=path - # construct icon_url based on type of storage path (icons.svg contains icons for each) - self.icon_url:str=url_for("internal", filename="icons.svg") + "#" + ICON[self.type] - - def to_dict(self): - return {key: value for key, value in vars(self).items()} - -################################################################################ -# helper function to find path details for move destinations - used in html -# for move DBox to show potential storage paths to move files into -################################################################################ -def MovePathDetails(): - """helper function to find path details for move destinations - - used in html/javascript for move Dialog Box to show potential storage paths to move files into - - Args: - None - - Returns: - ret (List[PathDetail]): a list of Path Details for where files can be moved - - """ - ret=[] - sps=Path.query.join(PathType).filter(PathType.name=="Storage").all() - for p in sps: - obj = PathDetail( ptype="Storage", path=p.path_prefix.replace("static/Storage/","") ) - ret.append( obj.to_dict() ) - ips=Path.query.join(PathType).filter(PathType.name=="Import").all() - for p in ips: - obj = PathDetail( ptype="Import", path=p.path_prefix.replace("static/Import/","") ) - ret.append( obj.to_dict() ) - return ret