mirror of
https://gitlab.com/tildes/tildes.git
synced 2026-04-16 06:18:34 +02:00
Apply topic tag filters when viewing a single tag
Includes HTML updates to let user click into unfiltered view, when viewing a single tag.
This commit is contained in:
@@ -71,7 +71,7 @@
|
||||
<li>User settings</li>
|
||||
|
||||
<ul class="nav">
|
||||
{% if not (tag or unfiltered) %}
|
||||
{% if not unfiltered %}
|
||||
<li><details>
|
||||
<summary>Filtered topic tags ({{ request.user.filtered_topic_tags|length }})</summary>
|
||||
<ul class="topic-tags">
|
||||
|
||||
@@ -112,6 +112,12 @@
|
||||
Showing only topics with the tag "{{ tag|replace('_', ' ') }}".
|
||||
<a href="{{ request.current_listing_normal_url() }}">Back to normal view</a>
|
||||
{% endif %}
|
||||
|
||||
{% if request.user.filtered_topic_tags and not unfiltered %}
|
||||
<br>
|
||||
Topic tag filters active (see sidebar).
|
||||
<a href="{{ request.current_listing_normal_url({'tag': tag, 'unfiltered': 'true'}) }}">View unfiltered list</a>
|
||||
{% endif %}
|
||||
{% elif unfiltered %}
|
||||
Showing unfiltered topic list.
|
||||
<a href="{{ request.current_listing_normal_url() }}">Back to normal view</a>
|
||||
|
||||
@@ -213,11 +213,20 @@ def get_group_topics( # noqa
|
||||
if after:
|
||||
query = query.after_id36(after)
|
||||
|
||||
# apply topic tag filters unless they're disabled or viewing a single tag
|
||||
if request.user and request.user.filtered_topic_tags and not (tag or unfiltered):
|
||||
# apply topic tag filters unless they're disabled
|
||||
if request.user and request.user.filtered_topic_tags and not unfiltered:
|
||||
filtered_topic_tags = request.user.filtered_topic_tags
|
||||
|
||||
# if viewing single tag, don't filter that tag and its ancestors
|
||||
# for example, if viewing "ask.survey", don't filter "ask.survey" or "ask"
|
||||
if tag:
|
||||
filtered_topic_tags = [
|
||||
ft for ft in filtered_topic_tags if not tag.descendant_of(ft)
|
||||
]
|
||||
|
||||
query = query.filter(
|
||||
~Topic.tags.descendant_of( # type: ignore
|
||||
any_(cast(request.user.filtered_topic_tags, TagList))
|
||||
any_(cast(filtered_topic_tags, TagList))
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user