diff --git a/app/main/routes.py b/app/main/routes.py index 08b7cc7e..9a2b3550 100644 --- a/app/main/routes.py +++ b/app/main/routes.py @@ -147,7 +147,7 @@ def home_page(type, sort): @bp.route('/topics', methods=['GET']) def list_topics(): verification_warning() - topics = Topic.query.order_by(Topic.name).all() + topics = Topic.query.filter_by(parent_id=None).order_by(Topic.name).all() return render_template('list_topics.html', topics=topics, title=_('Browse by topic'), low_bandwidth=request.cookies.get('low_bandwidth', '0') == '1', diff --git a/app/templates/topic/show_topic.html b/app/templates/topic/show_topic.html index 3af75077..9d837766 100644 --- a/app/templates/topic/show_topic.html +++ b/app/templates/topic/show_topic.html @@ -17,7 +17,14 @@

{{ topic.name }}

- + {% if sub_topics %} +

{{ _('Sub-topics') }}

+ + {% endif %} {% include "community/_community_nav.html" %} {% if post_layout == 'masonry' or post_layout == 'masonry_wide' %}
diff --git a/app/topic/routes.py b/app/topic/routes.py index 55e2eaf1..f58bdded 100644 --- a/app/topic/routes.py +++ b/app/topic/routes.py @@ -77,9 +77,12 @@ def show_topic(topic_name): topic_name=topic_name, page=posts.prev_num, sort=sort, layout=post_layout) if posts.has_prev and page != 1 else None + sub_topics = Topic.query.filter_by(parent_id=topic.id).order_by(Topic.name).all() + return render_template('topic/show_topic.html', title=_(topic.name), posts=posts, topic=topic, sort=sort, page=page, post_layout=post_layout, next_url=next_url, prev_url=prev_url, topic_communities=topic_communities, content_filters=content_filters, + sub_topics=sub_topics, rss_feed=f"https://{current_app.config['SERVER_NAME']}/topic/{topic_name}.rss", rss_feed_name=f"{topic.name} on {g.site.name}", show_post_community=True, moderating_communities=moderating_communities(current_user.get_id()),