From 6d5cd11612f0bd1621417481ac7a6ad61fa54cfa Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Wed, 9 Sep 2020 13:09:48 -0700 Subject: [PATCH] Let search_core return tags as real lists. This lets search.html deal with real objects instead of playing with dumed-down strings. --- .../backend/endpoints/photo_endpoints.py | 12 +++++------- frontends/etiquette_flask/templates/search.html | 12 ++++++------ 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/frontends/etiquette_flask/backend/endpoints/photo_endpoints.py b/frontends/etiquette_flask/backend/endpoints/photo_endpoints.py index ffcd573..d0f9131 100644 --- a/frontends/etiquette_flask/backend/endpoints/photo_endpoints.py +++ b/frontends/etiquette_flask/backend/endpoints/photo_endpoints.py @@ -382,13 +382,6 @@ def get_search_core(): search_kwargs = next(search_generator) # print(search_kwargs) - # The search has converted many arguments into sets or other types. - # Convert them back into something that will display nicely on the search form. - tagname_helper = lambda tags: [tag.name for tag in tags] if tags else None - search_kwargs['tag_musts'] = tagname_helper(search_kwargs['tag_musts']) - search_kwargs['tag_mays'] = tagname_helper(search_kwargs['tag_mays']) - search_kwargs['tag_forbids'] = tagname_helper(search_kwargs['tag_forbids']) - warnings = set() search_results = [] for item in search_generator: @@ -474,6 +467,11 @@ def get_search_json(): author_helper = lambda users: ', '.join(user.username for user in users) if users else None search_kwargs['author'] = author_helper(search_kwargs['author']) + tagname_helper = lambda tags: [tag.name for tag in tags] if tags else None + search_kwargs['tag_musts'] = tagname_helper(search_kwargs['tag_musts']) + search_kwargs['tag_mays'] = tagname_helper(search_kwargs['tag_mays']) + search_kwargs['tag_forbids'] = tagname_helper(search_kwargs['tag_forbids']) + search_results['results'] = [ etiquette.jsonify.photo(result, include_albums=False) if isinstance(result, etiquette.objects.Photo) else diff --git a/frontends/etiquette_flask/templates/search.html b/frontends/etiquette_flask/templates/search.html index 5d06ff5..4f1b203 100644 --- a/frontends/etiquette_flask/templates/search.html +++ b/frontends/etiquette_flask/templates/search.html @@ -185,11 +185,11 @@