misc ui sorting fixes and cleanup
parent
83a0702341
commit
947f06ea08
|
@ -8,7 +8,6 @@ from photoapp.thumb import ThumbGenerator
|
|||
from photoapp.types import Photo, PhotoSet, Tag, TagItem, PhotoStatus, User
|
||||
from photoapp.common import pwhash
|
||||
from photoapp.api import PhotosApi, LibraryManager
|
||||
from photoapp.storage import FilesystemAdapter
|
||||
from photoapp.dbutils import SAEnginePlugin, SATool, db, get_db_engine
|
||||
from photoapp.utils import mime2ext, auth, require_auth, photoset_auth_filter, slugify
|
||||
from photoapp.storage import uri_to_storage
|
||||
|
@ -134,9 +133,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)
|
||||
|
@ -211,8 +210,9 @@ class DateView(object):
|
|||
dt_end = dt + timedelta(days=1)
|
||||
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). \
|
||||
images = photoset_auth_filter(db.query(PhotoSet)). \
|
||||
filter(and_(PhotoSet.date >= dt, 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)
|
||||
|
|
|
@ -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):
|
||||
|
|
Loading…
Reference in New Issue