From 343ce508bf31b963e87469e8afb6ec567718b81f Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Thu, 24 Sep 2020 14:26:51 -0700 Subject: [PATCH] Add search UI for yield_albums. --- etiquette/photodb.py | 2 ++ etiquette/searchhelpers.py | 6 ++++++ .../etiquette_flask/backend/endpoints/photo_endpoints.py | 5 ++++- frontends/etiquette_flask/templates/search.html | 5 +++++ 4 files changed, 17 insertions(+), 1 deletion(-) diff --git a/etiquette/photodb.py b/etiquette/photodb.py index 8e58a78..3b5ab07 100644 --- a/etiquette/photodb.py +++ b/etiquette/photodb.py @@ -675,6 +675,7 @@ class PDBPhotoMixin: has_thumbnail = searchhelpers.normalize_has_thumbnail(has_thumbnail) is_searchhidden = searchhelpers.normalize_is_searchhidden(is_searchhidden) mimetype = searchhelpers.normalize_extension(mimetype) + yield_albums = searchhelpers.normalize_yield_albums(yield_albums) if has_tags is False: tag_musts = None @@ -763,6 +764,7 @@ class PDBPhotoMixin: 'limit': limit, 'offset': offset or None, 'orderby': giveback_orderby or None, + 'yield_albums': yield_albums, } yield parameters diff --git a/etiquette/searchhelpers.py b/etiquette/searchhelpers.py index 13bcd6c..922ce08 100644 --- a/etiquette/searchhelpers.py +++ b/etiquette/searchhelpers.py @@ -385,6 +385,12 @@ def normalize_tag_expression(expression): return expression +def normalize_yield_albums(yield_albums): + ''' + See etiquette.helpers.truthystring. + ''' + return helpers.truthystring(yield_albums) + EXIST_FORMAT = ''' {operator} ( SELECT 1 FROM photo_tag_rel WHERE photos.id == photo_tag_rel.photoid diff --git a/frontends/etiquette_flask/backend/endpoints/photo_endpoints.py b/frontends/etiquette_flask/backend/endpoints/photo_endpoints.py index f154432..d088a9f 100644 --- a/frontends/etiquette_flask/backend/endpoints/photo_endpoints.py +++ b/frontends/etiquette_flask/backend/endpoints/photo_endpoints.py @@ -325,6 +325,7 @@ def get_search_core(): extension_not = request.args.get('extension_not') mimetype = request.args.get('mimetype') is_searchhidden = request.args.get('is_searchhidden', False) + yield_albums = request.args.get('yield_albums', True) limit = request.args.get('limit') # This is being pre-processed because the site enforces a maximum value @@ -378,7 +379,9 @@ def get_search_core(): 'orderby': orderby, 'warning_bag': warning_bag, - 'give_back_parameters': True + 'give_back_parameters': True, + + 'yield_albums': yield_albums, } # print(search_kwargs) search_generator = common.P.search(**search_kwargs) diff --git a/frontends/etiquette_flask/templates/search.html b/frontends/etiquette_flask/templates/search.html index 3b149ca..e38ebbb 100644 --- a/frontends/etiquette_flask/templates/search.html +++ b/frontends/etiquette_flask/templates/search.html @@ -294,6 +294,10 @@ +