misc ui sorting fixes and cleanup

This commit is contained in:
dave 2019-07-05 00:28:57 -07:00
parent 83a0702341
commit 3608f6c1f2
2 changed files with 5 additions and 10 deletions

View File

@ -134,9 +134,9 @@ class PhotosWeb(object):
dt = datetime.strptime(fromdate, "%Y-%m-%d")
dt_end = dt + timedelta(days=1)
photos = db.query(PhotoSet).filter(and_(PhotoSet.date >= dt,
PhotoSet.date < dt_end)).order_by(PhotoSet.date)
PhotoSet.date < dt_end)).order_by(PhotoSet.date.desc())
num_photos = db.query(func.count(PhotoSet.id)). \
filter(and_(PhotoSet.date >= dt, PhotoSet.date < dt_end)).order_by(PhotoSet.date).scalar()
filter(and_(PhotoSet.date >= dt, PhotoSet.date < dt_end)).order_by(PhotoSet.date.desc()).scalar()
if uuid:
photos = db.query(PhotoSet).filter(PhotoSet.uuid == uuid)
@ -212,7 +212,7 @@ class DateView(object):
total_sets = photoset_auth_filter(db.query(func.count(PhotoSet.id))). \
filter(and_(PhotoSet.date >= dt, PhotoSet.date < dt_end)).first()[0]
images = photoset_auth_filter(db.query(PhotoSet)).filter(and_(PhotoSet.date >= dt,
PhotoSet.date < dt_end)).order_by(PhotoSet.date). \
PhotoSet.date < dt_end)).order_by(PhotoSet.date.desc()). \
offset(page * pgsize).limit(pgsize).all()
yield self.master.render("date.html", page=page, pgsize=pgsize, total_sets=total_sets,
images=[i for i in images], date=dt)
@ -354,7 +354,8 @@ class TagView(object):
if uuid == "untagged":
numphotos = photoset_auth_filter(db.query(func.count(PhotoSet.id))). \
filter(~PhotoSet.id.in_(db.query(TagItem.set_id))).scalar()
photos = photoset_auth_filter(db.query(PhotoSet)).filter(~PhotoSet.id.in_(db.query(TagItem.set_id))).\
photos = photoset_auth_filter(db.query(PhotoSet)).filter(~PhotoSet.id.in_(db.query(TagItem.set_id))). \
order_by(PhotoSet.date.desc()). \
offset(page * pgsize). \
limit(pgsize).all()
yield self.master.render("untagged.html", images=photos, total_items=numphotos, pgsize=pgsize, page=page)

View File

@ -49,17 +49,13 @@ class FilesystemAdapter(StorageAdapter):
self.root = root # root path
def exists(self, path):
# TODO return true/false if the file path exists
return os.path.exists(self._abspath(path))
def open(self, path, mode):
# TODO return a handle to the path. this should work as a context manager
os.makedirs(os.path.dirname(self._abspath(path)), exist_ok=True)
return open(self._abspath(path), mode)
def delete(self, path):
# TODO delete the file
# TODO prune empty directories that were components of $path
os.unlink(self._abspath(path))
def getsize(self, path):
@ -166,7 +162,6 @@ class MinioAdapter(StorageAdapter):
raise
def open(self, path, mode):
# TODO return a handle to the path. this should work as a context manager
if "r" in mode:
return S3ReadProxy(self.s3.get_object(Bucket=self.bucket, Key=os.path.join(self.prefix, path))["Body"])
elif "w" in mode:
@ -175,7 +170,6 @@ class MinioAdapter(StorageAdapter):
raise Exception("unknown file open mode")
def delete(self, path):
# TODO handle verification of return status
self.s3.delete_object(Bucket=self.bucket, Key=os.path.join(self.prefix, path))
def getsize(self, path):