now use eval() for GetEntries*Fold*, and much better fix for bug where next/prev was breaking with inputs with spaces in names -- dont need those inputs anyway, JUST pass next or prev and the rest comes from pa_user_state now
This commit is contained in:
26
files.py
26
files.py
@@ -238,6 +238,7 @@ def GetEntriesInFolderView( OPT, prefix ):
|
|||||||
# this can occur if the path in settings does not exist as it wont be in # the DB
|
# this can occur if the path in settings does not exist as it wont be in # the DB
|
||||||
if not dir:
|
if not dir:
|
||||||
return entries, 0
|
return entries, 0
|
||||||
|
# dirs cant be sorted by date really, so do best I can for now
|
||||||
if OPT.noo == "Z to A" or OPT.noo == "Newest":
|
if OPT.noo == "Z to A" or OPT.noo == "Newest":
|
||||||
entries+= Entry.query.join(EntryDirLink).join(FileType).filter(EntryDirLink.dir_eid==dir.id).filter(FileType.name=='Directory').order_by(Entry.name.desc()).all()
|
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
|
# just do A to Z / Oldest by default or if no valid option
|
||||||
@@ -245,26 +246,15 @@ def GetEntriesInFolderView( OPT, prefix ):
|
|||||||
entries+= Entry.query.join(EntryDirLink).join(FileType).filter(EntryDirLink.dir_eid==dir.id).filter(FileType.name=='Directory').order_by(Entry.name).all()
|
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)
|
# add any files at the current CWD (based on dir_eid in DB)
|
||||||
if OPT.noo == "Oldest":
|
join="Entry.query.join(File).join(EntryDirLink).filter(EntryDirLink.dir_eid==dir.id)"
|
||||||
file_entries=Entry.query.join(File).join(EntryDirLink).filter(EntryDirLink.dir_eid==dir.id).order_by(File.year,File.month,File.day,Entry.name).offset(OPT.offset).limit(OPT.how_many).all()
|
file_entries= eval( f"{join}.{OPT.order}.offset(OPT.offset).limit(OPT.how_many).all()")
|
||||||
last_entry=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)
|
|
||||||
elif OPT.noo == "Newest":
|
|
||||||
file_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(OPT.offset).limit(OPT.how_many).all()
|
|
||||||
last_entry=Entry.query.join(File).join(EntryDirLink).filter(EntryDirLink.dir_eid==dir.id).order_by(File.year,File.month,File.day,Entry.name)
|
|
||||||
elif OPT.noo == "Z to A":
|
|
||||||
file_entries=Entry.query.join(File).join(EntryDirLink).filter(EntryDirLink.dir_eid==dir.id).order_by(Entry.name.desc()).offset(OPT.offset).limit(OPT.how_many).all()
|
|
||||||
last_entry=Entry.query.join(File).join(EntryDirLink).filter(EntryDirLink.dir_eid==dir.id).order_by(Entry.name)
|
|
||||||
# just do A to Z by default or if no valid option
|
|
||||||
else:
|
|
||||||
file_entries=Entry.query.join(File).join(EntryDirLink).filter(EntryDirLink.dir_eid==dir.id).order_by(Entry.name).offset(OPT.offset).limit(OPT.how_many).all()
|
|
||||||
last_entry=Entry.query.join(File).join(EntryDirLink).filter(EntryDirLink.dir_eid==dir.id).order_by(Entry.name.desc())
|
|
||||||
if OPT.offset == 0 and len(file_entries):
|
if OPT.offset == 0 and len(file_entries):
|
||||||
OPT.first_eid = file_entries[0].id
|
OPT.first_eid = file_entries[0].id
|
||||||
if len(file_entries):
|
num_entries = eval( f"{join}.count()" )
|
||||||
num_entries=last_entry.count()
|
last_entry = eval( f"{join}.{OPT.last_order}.limit(1).first()" )
|
||||||
le=last_entry.limit(1).all()
|
if last_entry:
|
||||||
if len(le):
|
OPT.last_eid = last_entry.id
|
||||||
OPT.last_eid = le[0].id
|
|
||||||
|
|
||||||
entries += file_entries;
|
entries += file_entries;
|
||||||
return entries, num_entries
|
return entries, num_entries
|
||||||
|
|||||||
@@ -1,11 +1,3 @@
|
|||||||
// this is needed as serliazeArray doesnt handle spaces in values
|
|
||||||
// so we wrap it in this func
|
|
||||||
$.fn.serializeAndEncode = function() {
|
|
||||||
return $.map(this.serializeArray(), function(val) {
|
|
||||||
return [val.name, encodeURIComponent(val.value)].join('=');
|
|
||||||
}).join('&');
|
|
||||||
};
|
|
||||||
|
|
||||||
// grab all selected thumbnails and return a <div> containing the thumbnails
|
// grab all selected thumbnails and return a <div> containing the thumbnails
|
||||||
// with extra yr and date attached as attributes so we can set the default
|
// with extra yr and date attached as attributes so we can set the default
|
||||||
// dir name for a move directory - not used in del, but no harm to include them
|
// dir name for a move directory - not used in del, but no harm to include them
|
||||||
|
|||||||
Reference in New Issue
Block a user