chg: [tags] search messages by tags

This commit is contained in:
terrtia 2023-12-08 16:05:10 +01:00
parent 73185f19fd
commit 3add9b0a33
No known key found for this signature in database
GPG key ID: 1E1B1F50D84613D0
3 changed files with 37 additions and 1 deletions

View file

@ -275,6 +275,15 @@ def tags_search_items():
dict_tagged['date'] = Date.sanitise_date_range('', '', separator='-') dict_tagged['date'] = Date.sanitise_date_range('', '', separator='-')
return render_template("tags/search_obj_by_tags.html", bootstrap_label=bootstrap_label, dict_tagged=dict_tagged) return render_template("tags/search_obj_by_tags.html", bootstrap_label=bootstrap_label, dict_tagged=dict_tagged)
@tags_ui.route('/tag/search/message')
@login_required
@login_read_only
def tags_search_messages():
object_type = 'message'
dict_tagged = {"object_type": object_type, "object_name": object_type.title() + "s"}
dict_tagged['date'] = Date.sanitise_date_range('', '', separator='-')
return render_template("tags/search_obj_by_tags.html", bootstrap_label=bootstrap_label, dict_tagged=dict_tagged)
@tags_ui.route('/tag/search/domain') @tags_ui.route('/tag/search/domain')
@login_required @login_required
@login_read_only @login_read_only
@ -337,7 +346,7 @@ def get_obj_by_tags():
# TODO REPLACE ME # TODO REPLACE ME
dict_obj = Tag.get_obj_by_tags(object_type, list_tag, date_from=date_from, date_to=date_to, page=page) dict_obj = Tag.get_obj_by_tags(object_type, list_tag, date_from=date_from, date_to=date_to, page=page)
print(dict_obj) # print(dict_obj)
if dict_obj['tagged_obj']: if dict_obj['tagged_obj']:
dict_tagged = {"object_type": object_type, "object_name": object_type.title() + "s", dict_tagged = {"object_type": object_type, "object_name": object_type.title() + "s",

View file

@ -16,6 +16,12 @@
Search Items by Tags Search Items by Tags
</a> </a>
</li> </li>
<li class="nav-item">
<a class="nav-link" href="{{ url_for('tags_ui.tags_search_messages') }}" id="nav_tags_search_message">
<i class="fas fa-comment-dots"></i>
Search Messages by Tags
</a>
</li>
<li class="nav-item"> <li class="nav-item">
<a class="nav-link" href="{{ url_for('tags_ui.tags_search_domains') }}" id="nav_tags_search_domain"> <a class="nav-link" href="{{ url_for('tags_ui.tags_search_domains') }}" id="nav_tags_search_domain">
<i class="fab fa-html5"></i> <i class="fab fa-html5"></i>

View file

@ -67,6 +67,9 @@
<th>Date</th> <th>Date</th>
<th style="max-width: 800px;">Item</th> <th style="max-width: 800px;">Item</th>
<th>Action</th> <th>Action</th>
{%elif dict_tagged["object_type"]=="message"%}
<th>Date</th>
<th style="max-width: 800px;">Message</th>
{%endif%} {%endif%}
</tr> </tr>
</thead> </thead>
@ -123,6 +126,24 @@
</td> </td>
</tr> </tr>
{% endfor %} {% endfor %}
{%elif dict_tagged["object_type"]=="message"%}
{% for dict_obj in dict_tagged["tagged_obj"] %}
<tr>
<td class="pb-0">{{ dict_obj['full_date'] }}</td>
<td class="pb-0">
<a target="_blank" href="{{ dict_obj['link'] }}" class="text-secondary">
<div style="line-height:0.9;">{{ dict_obj['id'] }}</div>
</a>
<div class="mb-2">
{% for tag in dict_obj['tags'] %}
<a href="{{ url_for('tags_ui.get_obj_by_tags') }}?object_type={{dict_tagged['object_type']}}&ltags={{ tag }}">
<span class="badge badge-{{ bootstrap_label[loop.index0 % 5] }}">{{ tag }}</span>
</a>
{% endfor %}
</div>
</td>
</tr>
{% endfor %}
{%elif dict_tagged["object_type"]=="item"%} {%elif dict_tagged["object_type"]=="item"%}
{% for dict_obj in dict_tagged["tagged_obj"] %} {% for dict_obj in dict_tagged["tagged_obj"] %}