Let search_core return tags as real lists.
This lets search.html deal with real objects instead of playing with dumed-down strings.
This commit is contained in:
parent
d585fe92a9
commit
6d5cd11612
2 changed files with 11 additions and 13 deletions
|
@ -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
|
||||
|
|
|
@ -185,11 +185,11 @@
|
|||
<ul class="search_builder_tagger">
|
||||
{% set key="tag_" + tagtype %}
|
||||
{% if search_kwargs[key] %}
|
||||
{% for tagname in search_kwargs[key] %}
|
||||
{% for tag in search_kwargs[key] %}
|
||||
<li class="search_builder_{{tagtype}}_inputted">
|
||||
<span class="tag_object">{{tagname}}</span>{{-''-}}
|
||||
<button class="remove_tag_button red_button"
|
||||
onclick="return remove_searchtag(ul_{{tagtype}}, '{{tagname}}', inputted_{{tagtype}});"></button>
|
||||
{{tag_object.tag_object(tag, link='info', with_alt_description=True)}}<!--
|
||||
--><button class="remove_tag_button red_button"
|
||||
onclick="return remove_searchtag(ul_{{tagtype}}, '{{tag.name}}', inputted_{{tagtype}});"></button>
|
||||
</li>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
|
@ -664,8 +664,8 @@ var inputted_forbids = [];
|
|||
{% for tagtype in ["musts", "mays", "forbids"] %}
|
||||
{% set key="tag_" + tagtype %}
|
||||
{% if search_kwargs[key] %}
|
||||
{% for tagname in search_kwargs[key] %}
|
||||
inputted_{{tagtype}}.push("{{tagname}}");
|
||||
{% for tag in search_kwargs[key] %}
|
||||
inputted_{{tagtype}}.push("{{tag.name}}");
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
|
Loading…
Reference in a new issue