diff --git a/tildes/tildes/templates/topic_listing.jinja2 b/tildes/tildes/templates/topic_listing.jinja2
index a148902..e9726b5 100644
--- a/tildes/tildes/templates/topic_listing.jinja2
+++ b/tildes/tildes/templates/topic_listing.jinja2
@@ -112,6 +112,11 @@
Showing only topics with the tag "{{ tag|replace('_', ' ') }}".
Back to normal view
{% endif %}
+ {% if request.user.filtered_topic_tags and not unfiltered %}
+
+ Topic tag filters active (see sidebar).
+ View unfiltered list
+ {% endif %}
{% elif unfiltered %}
Showing unfiltered topic list.
Back to normal view
diff --git a/tildes/tildes/views/topic.py b/tildes/tildes/views/topic.py
index 61ad30f..fd44e26 100644
--- a/tildes/tildes/views/topic.py
+++ b/tildes/tildes/views/topic.py
@@ -213,11 +213,21 @@ 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
+ if tag:
+ filtered_topic_tags = [
+ ft
+ for ft in filtered_topic_tags
+ if ft != tag.path and not tag.path.startswith(ft + ".")
+ ]
+
query = query.filter(
~Topic.tags.descendant_of( # type: ignore
- any_(cast(request.user.filtered_topic_tags, TagList))
+ any_(cast(filtered_topic_tags, TagList))
)
)