chg: [tags search] show last tag(s) date if no result

pull/607/merge
terrtia 2024-09-19 11:21:06 +02:00
parent a5a2f90e8b
commit 8a267e2a83
No known key found for this signature in database
GPG Key ID: 1E1B1F50D84613D0
2 changed files with 31 additions and 10 deletions

View File

@ -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
@ -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 = []
@ -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']}
@ -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']

View File

@ -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>