Skip to content

Commit

Permalink
chg: [tags] search messages by tags
Browse files Browse the repository at this point in the history
  • Loading branch information
Terrtia committed Dec 8, 2023
1 parent 73185f1 commit 3add9b0
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
11 changes: 10 additions & 1 deletion var/www/blueprints/tags_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,15 @@ def tags_search_items():
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/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')
@login_required
@login_read_only
Expand Down Expand Up @@ -337,7 +346,7 @@ def get_obj_by_tags():

# TODO REPLACE ME
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']:
dict_tagged = {"object_type": object_type, "object_name": object_type.title() + "s",
Expand Down
6 changes: 6 additions & 0 deletions var/www/templates/tags/menu_sidebar.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ <h5 class="d-flex text-muted w-100" id="nav_tags_search">
Search Items by Tags
</a>
</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">
<a class="nav-link" href="{{ url_for('tags_ui.tags_search_domains') }}" id="nav_tags_search_domain">
<i class="fab fa-html5"></i>
Expand Down
21 changes: 21 additions & 0 deletions var/www/templates/tags/search_obj_by_tags.html
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@
<th>Date</th>
<th style="max-width: 800px;">Item</th>
<th>Action</th>
{%elif dict_tagged["object_type"]=="message"%}
<th>Date</th>
<th style="max-width: 800px;">Message</th>
{%endif%}
</tr>
</thead>
Expand Down Expand Up @@ -123,6 +126,24 @@
</td>
</tr>
{% 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"%}
{% for dict_obj in dict_tagged["tagged_obj"] %}
Expand Down

0 comments on commit 3add9b0

Please sign in to comment.