Let search_core return author as real list.
This lets search.html deal with real objects instead of playing with dumed-down strings.
This commit is contained in:
parent
94b811b3b1
commit
d585fe92a9
4 changed files with 10 additions and 4 deletions
|
@ -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['sort_tags'] = jinja_filters.sort_tags
|
||||||
site.jinja_env.filters['timestamp_to_8601'] = jinja_filters.timestamp_to_8601
|
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['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.jinja_env.globals['make_attributes'] = jinja_filters.make_attributes
|
||||||
site.debug = True
|
site.debug = True
|
||||||
|
|
||||||
|
|
|
@ -384,9 +384,6 @@ def get_search_core():
|
||||||
|
|
||||||
# The search has converted many arguments into sets or other types.
|
# The search has converted many arguments into sets or other types.
|
||||||
# Convert them back into something that will display nicely on the search form.
|
# 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
|
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_musts'] = tagname_helper(search_kwargs['tag_musts'])
|
||||||
search_kwargs['tag_mays'] = tagname_helper(search_kwargs['tag_mays'])
|
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['extension_not'] = join_helper(search_kwargs['extension_not'])
|
||||||
search_kwargs['mimetype'] = join_helper(search_kwargs['mimetype'])
|
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'] = [
|
search_results['results'] = [
|
||||||
etiquette.jsonify.photo(result, include_albums=False)
|
etiquette.jsonify.photo(result, include_albums=False)
|
||||||
if isinstance(result, etiquette.objects.Photo) else
|
if isinstance(result, etiquette.objects.Photo) else
|
||||||
|
|
|
@ -41,3 +41,8 @@ def timestamp_to_string(timestamp, format):
|
||||||
|
|
||||||
def timestamp_to_naturaldate(timestamp):
|
def timestamp_to_naturaldate(timestamp):
|
||||||
return timestamp_to_string(timestamp, '%B %d, %Y')
|
return timestamp_to_string(timestamp, '%B %d, %Y')
|
||||||
|
|
||||||
|
def users_to_usernames(users):
|
||||||
|
if not users:
|
||||||
|
return []
|
||||||
|
return [user.username for user in users]
|
||||||
|
|
|
@ -271,7 +271,7 @@
|
||||||
name="extension_not" placeholder="Forbid extension(s)">
|
name="extension_not" placeholder="Forbid extension(s)">
|
||||||
|
|
||||||
<input type="text" class="basic_param"
|
<input type="text" class="basic_param"
|
||||||
{%if search_kwargs['author']%} value="{{search_kwargs['author']}}" {%endif%}
|
value="{{search_kwargs['author']|users_to_usernames|comma_join}}"
|
||||||
name="author" placeholder="Author">
|
name="author" placeholder="Author">
|
||||||
|
|
||||||
<select name="limit" class="basic_param">
|
<select name="limit" class="basic_param">
|
||||||
|
|
Loading…
Reference in a new issue