|
|
|
@ -8,7 +8,7 @@ from urllib.parse import urlparse
|
|
|
|
|
from datetime import datetime, timedelta
|
|
|
|
|
from photoapp.thumbtool import ThumbGenerator
|
|
|
|
|
from photoapp.types import APPROOT, Photo, PhotoSet, Tag, TagItem, PhotoStatus, User, mime2ext, \
|
|
|
|
|
regular_mimes, video_mimes
|
|
|
|
|
regular_mimes, video_mimes, ftypes
|
|
|
|
|
from photoapp.dbsession import DatabaseSession
|
|
|
|
|
from photoapp.common import pwhash
|
|
|
|
|
from photoapp.api import PhotosApi, LibraryManager
|
|
|
|
@ -67,7 +67,8 @@ class PhotosWeb(object):
|
|
|
|
|
"all_tags": tagq,
|
|
|
|
|
"path": cherrypy.request.path_info,
|
|
|
|
|
"auth": auth(),
|
|
|
|
|
"PhotoStatus": PhotoStatus
|
|
|
|
|
"PhotoStatus": PhotoStatus,
|
|
|
|
|
"ftypes": ftypes
|
|
|
|
|
}
|
|
|
|
|
return ret
|
|
|
|
|
|
|
|
|
@ -441,6 +442,7 @@ class SearchView(object):
|
|
|
|
|
include_tags=None,
|
|
|
|
|
exclude_tags=None,
|
|
|
|
|
untagged=False,
|
|
|
|
|
include_formats=None,
|
|
|
|
|
before=None,
|
|
|
|
|
after=None,
|
|
|
|
|
set_before=None,
|
|
|
|
@ -464,6 +466,7 @@ class SearchView(object):
|
|
|
|
|
exclude_tags = cherryparam(exclude_tags)
|
|
|
|
|
add_tag = cherryparam(add_tag)
|
|
|
|
|
remove_tag = cherryparam(remove_tag)
|
|
|
|
|
include_formats = cherryparam(include_formats) or list(ftypes.keys())
|
|
|
|
|
|
|
|
|
|
untagged = untagged in frozenset([True, 1, "1", "yes"])
|
|
|
|
|
|
|
|
|
@ -518,6 +521,11 @@ class SearchView(object):
|
|
|
|
|
base = base \
|
|
|
|
|
.filter(PhotoSet.id.in_(db.query(Photo.set_id).filter(Photo.fname.like("%{}%".format(keywords_filename)))))
|
|
|
|
|
|
|
|
|
|
# TODO there are two filters that use a Photo subquery. They could probably be combined.
|
|
|
|
|
allowed_mimes = set().union(*[mime["mimes"] for ext, mime in ftypes.items() if ext in include_formats])
|
|
|
|
|
base = base.filter(PhotoSet.id.in_(
|
|
|
|
|
db.query(Photo.set_id).filter(Photo.format.in_(allowed_mimes))))
|
|
|
|
|
|
|
|
|
|
base = base \
|
|
|
|
|
.order_by(PhotoSet.date.desc())
|
|
|
|
|
|
|
|
|
@ -570,6 +578,7 @@ class SearchView(object):
|
|
|
|
|
include_tags=include_tags,
|
|
|
|
|
exclude_tags=exclude_tags,
|
|
|
|
|
selecting_untagged=untagged,
|
|
|
|
|
include_formats=include_formats,
|
|
|
|
|
images=[i for i in images],
|
|
|
|
|
total_sets=total_sets,
|
|
|
|
|
page=page,
|
|
|
|
|