Skip to content

Commit

Permalink
chg: [tags search] show last tag(s) date if no result
Browse files Browse the repository at this point in the history
  • Loading branch information
Terrtia committed Sep 19, 2024
1 parent a5a2f90 commit 8a267e2
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 10 deletions.
27 changes: 18 additions & 9 deletions var/www/blueprints/tags_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def galaxy_enable_tags():
@login_required
@login_read_only
def get_all_tags_enabled():
return jsonify(Tags.get_enabled_tags_with_synonyms_ui())
return jsonify(Tag.get_enabled_tags_with_synonyms_ui())

@tags_ui.route('/tag/confirm')
@login_required
Expand Down Expand Up @@ -353,7 +353,12 @@ def get_obj_by_tags():
date_from = date_from.replace('-', '')
if date_to:
date_to = date_to.replace('-', '')
date_today = Date.get_today_date_str()
if date_today == date_from == date_to:
date_from = None
date_to = None

# TODO REFACTOR ME
# unpack tags
list_tags = ltags.split(',')
list_tag = []
Expand All @@ -376,7 +381,7 @@ def get_obj_by_tags():
# print(dict_obj)

if dict_obj['tagged_obj']:
dict_tagged = {"object_type": object_type, "object_name": object_type.title() + "s",
dict_tagged = {
"tagged_obj": [], "page": dict_obj['page'], "nb_pages": dict_obj['nb_pages'],
"nb_first_elem": dict_obj['nb_first_elem'], "nb_last_elem": dict_obj['nb_last_elem'],
"nb_all_elem": dict_obj['nb_all_elem']}
Expand All @@ -388,15 +393,19 @@ def get_obj_by_tags():

dict_tagged['tab_keys'] = ail_objects.get_ui_obj_tag_table_keys(object_type)

if len(list_tag) == 1:
dict_tagged['current_tags'] = [ltags.replace('"', '\"')]
else:
dict_tagged['current_tags'] = list_tag
dict_tagged['current_tags_str'] = ltags

# return jsonify(dict_tagged)
else:
dict_tagged = {"object_type": object_type, "object_name": object_type.title() + "s"}
dict_tagged = {}
dict_tagged['tag_last_seen'] = Tag.get_tags_min_last_seen(list_tag, r_int=False)

dict_tagged['object_type'] = object_type
dict_tagged['object_name'] = f'{object_type.title()}s'

if len(list_tag) == 1:
dict_tagged['current_tags'] = [ltags.replace('"', '\"')]
else:
dict_tagged['current_tags'] = list_tag
dict_tagged['current_tags_str'] = ltags

if 'date' in dict_obj:
dict_tagged['date'] = dict_obj['date']
Expand Down
14 changes: 13 additions & 1 deletion var/www/templates/tags/search_obj_by_tags.html
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,19 @@
{% set target_url= target_url + "&date_from=" + dict_tagged['date']['date_from'] + "&date_to=" + dict_tagged['date']['date_to'] %}
{%endif%}
{% include 'pagination.html' %}
{% endwith %}
{% endwith %}

{% else %}
<h2>
{% if dict_tagged['date']['date_from'] %}{{ dict_tagged['date']['date_from'][0:4] }}-{{ dict_tagged['date']['date_from'][4:6] }}-{{ dict_tagged['date']['date_from'][6:8] }} {% endif %}
- {{ dict_tagged['date']['date_to'][0:4] }}-{{ dict_tagged['date']['date_to'][4:6] }}-{{ dict_tagged['date']['date_to'][6:8] }} No Result
</h2>
{% for tag in dict_tagged['current_tags'] %}
<span class="badge badge-secondary my-1">{{ tag }}"</span>
{% endfor %}
{% if dict_tagged['tag_last_seen'] %}
<h3 class="mt-2">Last Result: <a href="{{ url_for('tags_ui.get_obj_by_tags')}}?object_type={{ dict_tagged['object_type'] }}&ltags={{ dict_tagged['current_tags_str'] }}">{{ dict_tagged['tag_last_seen'][0:4] }}-{{ dict_tagged['tag_last_seen'][4:6] }}-{{ dict_tagged['tag_last_seen'][6:8] }}</a></h3>
{% endif %}
{%endif%}

</div>
Expand Down

0 comments on commit 8a267e2

Please sign in to comment.