file_{ip|sp|rbp} now use functions to view flat or folder, and consistently offer Oldest/Newest (per files) and A to Z, Z to A (dir and files)... folder view only does A to Z / Oldest as alpha sort for dirs (dirs dont currently contain date metadata, so unless I add it, it wont work and I dont really think its useful anyway)... BUT, its added to the TODO for another day
This commit is contained in:
50
files.py
50
files.py
@@ -133,6 +133,7 @@ def ViewingOptions( request ):
|
||||
offset=0
|
||||
size=128
|
||||
if 'files_sp' in request.path:
|
||||
noo="A to Z"
|
||||
folders=True
|
||||
cwd='static/Storage'
|
||||
elif 'files_rbp' in request.path:
|
||||
@@ -170,6 +171,19 @@ def ViewingOptions( request ):
|
||||
|
||||
return noo, grouping, how_many, offset, size, folders, cwd, root
|
||||
|
||||
def GetEntriesInFlatView( cwd, prefix, noo, offset, how_many ):
|
||||
entries=[]
|
||||
|
||||
if noo == "Oldest":
|
||||
entries+=Entry.query.join(File).join(EntryDirLink).join(Dir).join(PathDirLink).join(Path).filter(Path.path_prefix==prefix).order_by(File.year,File.month,File.day,Entry.name).offset(offset).limit(how_many).all()
|
||||
elif noo == "Newest":
|
||||
entries+=Entry.query.join(File).join(EntryDirLink).join(Dir).join(PathDirLink).join(Path).filter(Path.path_prefix==prefix).order_by(File.year.desc(),File.month.desc(),File.day.desc(),Entry.name).offset(offset).limit(how_many).all()
|
||||
elif noo == "Z to A":
|
||||
entries+=Entry.query.join(File).join(EntryDirLink).join(Dir).join(PathDirLink).join(Path).filter(Path.path_prefix==prefix).order_by(Entry.name.desc()).offset(offset).limit(how_many).all()
|
||||
else:
|
||||
entries+=Entry.query.join(File).join(EntryDirLink).join(Dir).join(PathDirLink).join(Path).filter(Path.path_prefix==prefix).order_by(Entry.name).offset(offset).limit(how_many).all()
|
||||
return entries
|
||||
|
||||
def GetEntriesInFolderView( cwd, prefix, noo, offset, how_many ):
|
||||
entries=[]
|
||||
# okay the root cwd is fake, so treat it specially - its Dir can be found by path with dir.rel_path=''
|
||||
@@ -183,12 +197,22 @@ def GetEntriesInFolderView( cwd, prefix, noo, offset, how_many ):
|
||||
if len(rp) and rp[0] == '/':
|
||||
rp=rp[1:]
|
||||
dir=Entry.query.join(Dir).join(PathDirLink).join(Path).filter(Dir.rel_path==rp).filter(Path.path_prefix==prefix).order_by(Entry.name).first()
|
||||
entries+= Entry.query.join(EntryDirLink).join(FileType).filter(EntryDirLink.dir_eid==dir.id).filter(FileType.name=='Directory').all()
|
||||
if noo == "Z to A" or "Newest":
|
||||
entries+= Entry.query.join(EntryDirLink).join(FileType).filter(EntryDirLink.dir_eid==dir.id).filter(FileType.name=='Directory').order_by(Entry.name.desc()).all()
|
||||
# just do A to Z / Oldest by default or if no valid option
|
||||
else:
|
||||
entries+= Entry.query.join(EntryDirLink).join(FileType).filter(EntryDirLink.dir_eid==dir.id).filter(FileType.name=='Directory').order_by(Entry.name).all()
|
||||
|
||||
# add any files at the current CWD (based on dir_eid in DB)
|
||||
if noo == "Oldest":
|
||||
entries+=Entry.query.join(File).join(EntryDirLink).filter(EntryDirLink.dir_eid==dir.id).order_by(File.year,File.month,File.day,Entry.name).offset(offset).limit(how_many).all()
|
||||
else:
|
||||
elif noo == "Newest":
|
||||
entries+=Entry.query.join(File).join(EntryDirLink).filter(EntryDirLink.dir_eid==dir.id).order_by(File.year.desc(),File.month.desc(),File.day.desc(),Entry.name).offset(offset).limit(how_many).all()
|
||||
elif noo == "Z to A":
|
||||
entries+=Entry.query.join(File).join(EntryDirLink).filter(EntryDirLink.dir_eid==dir.id).order_by(Entry.name.desc()).offset(offset).limit(how_many).all()
|
||||
# just do A to Z by default or if no valid option
|
||||
else:
|
||||
entries+=Entry.query.join(File).join(EntryDirLink).filter(EntryDirLink.dir_eid==dir.id).order_by(Entry.name).offset(offset).limit(how_many).all()
|
||||
return entries
|
||||
|
||||
################################################################################
|
||||
@@ -212,14 +236,10 @@ def files_ip():
|
||||
paths = settings.import_path.split("#")
|
||||
for path in paths:
|
||||
prefix = SymlinkName("Import",path,path+'/')
|
||||
|
||||
if folders:
|
||||
entries+=GetEntriesInFolderView( cwd, prefix, noo, offset, how_many )
|
||||
else:
|
||||
if noo == "Oldest":
|
||||
entries+=Entry.query.join(File).join(EntryDirLink).join(Dir).join(PathDirLink).join(Path).filter(Path.path_prefix==prefix).order_by(File.year,File.month,File.day,Entry.name).offset(offset).limit(how_many).all()
|
||||
if folders:
|
||||
entries+=GetEntriesInFolderView( cwd, prefix, noo, offset, how_many )
|
||||
else:
|
||||
entries+=Entry.query.join(File).join(EntryDirLink).join(Dir).join(PathDirLink).join(Path).filter(Path.path_prefix==prefix).order_by(File.year.desc(),File.month.desc(),File.day.desc(),Entry.name).offset(offset).limit(how_many).all()
|
||||
entries+=GetEntriesInFlatView( cwd, prefix, noo, offset, how_many )
|
||||
|
||||
return render_template("files.html", page_title='View Files (Import Path)', entry_data=entries, noo=noo, grouping=grouping, how_many=how_many, offset=offset, size=size, folders=folders, cwd=cwd, root=root )
|
||||
|
||||
@@ -236,14 +256,10 @@ def files_sp():
|
||||
paths = settings.storage_path.split("#")
|
||||
for path in paths:
|
||||
prefix = SymlinkName("Storage",path,path+'/')
|
||||
|
||||
if folders:
|
||||
entries+=GetEntriesInFolderView( cwd, prefix, noo, offset, how_many )
|
||||
else:
|
||||
if noo == "Oldest":
|
||||
entries+=Entry.query.join(File).join(EntryDirLink).join(Dir).join(PathDirLink).join(Path).filter(Path.path_prefix==prefix).order_by(File.year,File.month,File.day,Entry.name).offset(offset).limit(how_many).all()
|
||||
else:
|
||||
entries+=Entry.query.join(File).join(EntryDirLink).join(Dir).join(PathDirLink).join(Path).filter(Path.path_prefix==prefix).order_by(File.year.desc(),File.month.desc(),File.day.desc(),Entry.name).offset(offset).limit(how_many).all()
|
||||
entries+=GetEntriesInFlatView( cwd, prefix, noo, offset, how_many )
|
||||
|
||||
return render_template("files.html", page_title='View Files (Storage Path)', entry_data=entries, noo=noo, grouping=grouping, how_many=how_many, offset=offset, size=size, folders=folders, cwd=cwd, root=root )
|
||||
|
||||
@@ -261,14 +277,10 @@ def files_rbp():
|
||||
paths = settings.recycle_bin_path.split("#")
|
||||
for path in paths:
|
||||
prefix = SymlinkName("Bin",path,path+'/')
|
||||
|
||||
if folders:
|
||||
entries+=GetEntriesInFolderView( cwd, prefix, noo, offset, how_many )
|
||||
else:
|
||||
if noo == "Oldest":
|
||||
entries+=Entry.query.join(File).join(EntryDirLink).join(Dir).join(PathDirLink).join(Path).filter(Path.path_prefix==prefix).order_by(File.year,File.month,File.day,Entry.name).offset(offset).limit(how_many).all()
|
||||
else:
|
||||
entries+=Entry.query.join(File).join(EntryDirLink).join(Dir).join(PathDirLink).join(Path).filter(Path.path_prefix==prefix).order_by(File.year.desc(),File.month.desc(),File.day.desc(),Entry.name).offset(offset).limit(how_many).all()
|
||||
entries+=GetEntriesInFlatView( cwd, prefix, noo, offset, how_many )
|
||||
|
||||
return render_template("files.html", page_title='View Files (Bin Path)', entry_data=entries, noo=noo, grouping=grouping, how_many=how_many, offset=offset, size=size, folders=folders, cwd=cwd, root=root )
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
</div class="col my-auto">
|
||||
{% endif %}
|
||||
<div class="px-0 input-group col-lg-4">
|
||||
{{CreateSelect( "noo", noo, ["Oldest", "Newest"], "$('#offset').val(0)")|safe }}
|
||||
{{CreateSelect( "noo", noo, ["Oldest", "Newest","A to Z", "Z to A"], "$('#offset').val(0)")|safe }}
|
||||
{{CreateSelect( "how_many", how_many, ["10", "25", "50", "75", "100", "150", "200", "500"])|safe }}
|
||||
{% if folders %}
|
||||
<input type="hidden" name="grouping" id="grouping" value="{{grouping}}">
|
||||
|
||||
Reference in New Issue
Block a user