diff --git a/frontends/etiquette_flask/backend/common.py b/frontends/etiquette_flask/backend/common.py index 9f3c48f..2fa24d4 100644 --- a/frontends/etiquette_flask/backend/common.py +++ b/frontends/etiquette_flask/backend/common.py @@ -38,6 +38,7 @@ site.jinja_env.filters['file_link'] = jinja_filters.file_link site.jinja_env.filters['sort_tags'] = jinja_filters.sort_tags site.jinja_env.filters['timestamp_to_8601'] = jinja_filters.timestamp_to_8601 site.jinja_env.filters['timestamp_to_naturaldate'] = jinja_filters.timestamp_to_naturaldate +site.jinja_env.filters['users_to_usernames'] = jinja_filters.users_to_usernames site.jinja_env.globals['make_attributes'] = jinja_filters.make_attributes site.debug = True diff --git a/frontends/etiquette_flask/backend/endpoints/photo_endpoints.py b/frontends/etiquette_flask/backend/endpoints/photo_endpoints.py index 0f63ab3..ffcd573 100644 --- a/frontends/etiquette_flask/backend/endpoints/photo_endpoints.py +++ b/frontends/etiquette_flask/backend/endpoints/photo_endpoints.py @@ -384,9 +384,6 @@ def get_search_core(): # The search has converted many arguments into sets or other types. # Convert them back into something that will display nicely on the search form. - 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']) @@ -474,6 +471,9 @@ def get_search_json(): search_kwargs['extension_not'] = join_helper(search_kwargs['extension_not']) search_kwargs['mimetype'] = join_helper(search_kwargs['mimetype']) + author_helper = lambda users: ', '.join(user.username for user in users) if users else None + search_kwargs['author'] = author_helper(search_kwargs['author']) + search_results['results'] = [ etiquette.jsonify.photo(result, include_albums=False) if isinstance(result, etiquette.objects.Photo) else diff --git a/frontends/etiquette_flask/backend/jinja_filters.py b/frontends/etiquette_flask/backend/jinja_filters.py index 8e03181..c68e875 100644 --- a/frontends/etiquette_flask/backend/jinja_filters.py +++ b/frontends/etiquette_flask/backend/jinja_filters.py @@ -41,3 +41,8 @@ def timestamp_to_string(timestamp, format): def timestamp_to_naturaldate(timestamp): return timestamp_to_string(timestamp, '%B %d, %Y') + +def users_to_usernames(users): + if not users: + return [] + return [user.username for user in users] diff --git a/frontends/etiquette_flask/templates/search.html b/frontends/etiquette_flask/templates/search.html index 9e8bd71..5d06ff5 100644 --- a/frontends/etiquette_flask/templates/search.html +++ b/frontends/etiquette_flask/templates/search.html @@ -271,7 +271,7 @@ name="extension_not" placeholder="Forbid extension(s)">