diff --git a/app/search/routes.py b/app/search/routes.py index 8edbcef7..654be6fe 100644 --- a/app/search/routes.py +++ b/app/search/routes.py @@ -5,7 +5,8 @@ from sqlalchemy import or_ from app.models import Post from app.search import bp -from app.utils import moderating_communities, joined_communities, render_template, blocked_domains, blocked_instances +from app.utils import moderating_communities, joined_communities, render_template, blocked_domains, blocked_instances, \ + communities_banned_from @bp.route('/search', methods=['GET', 'POST']) @@ -29,6 +30,9 @@ def run_search(): instance_ids = blocked_instances(current_user.id) if instance_ids: posts = posts.filter(or_(Post.instance_id.not_in(instance_ids), Post.instance_id == None)) + banned_from = communities_banned_from(current_user.id) + if banned_from: + posts = posts.filter(Post.community_id.not_in(banned_from)) else: posts = posts.filter(Post.from_bot == False) posts = posts.filter(Post.nsfl == False) @@ -43,7 +47,7 @@ def run_search(): prev_url = url_for('search.run_search', page=posts.prev_num, q=q) if posts.has_prev and page != 1 else None return render_template('search/results.html', title=_('Search results for %(q)s', q=q), posts=posts, q=q, - next_url=next_url, prev_url=prev_url, + next_url=next_url, prev_url=prev_url, show_post_community=True, moderating_communities=moderating_communities(current_user.get_id()), joined_communities=joined_communities(current_user.get_id()), site=g.site) diff --git a/app/topic/routes.py b/app/topic/routes.py index 906ec7ee..2e258757 100644 --- a/app/topic/routes.py +++ b/app/topic/routes.py @@ -16,7 +16,8 @@ from app.topic import bp from app import db, celery, cache from app.topic.forms import ChooseTopicsForm from app.utils import render_template, user_filters_posts, moderating_communities, joined_communities, \ - community_membership, blocked_domains, validation_required, mimetype_from_url, blocked_instances + community_membership, blocked_domains, validation_required, mimetype_from_url, blocked_instances, \ + communities_banned_from @bp.route('/topic/', methods=['GET']) @@ -68,6 +69,9 @@ def show_topic(topic_path): instance_ids = blocked_instances(current_user.id) if instance_ids: posts = posts.filter(or_(Post.instance_id.not_in(instance_ids), Post.instance_id == None)) + banned_from = communities_banned_from(current_user.id) + if banned_from: + posts = posts.filter(Post.community_id.not_in(banned_from)) # sorting if sort == '' or sort == 'hot': diff --git a/app/user/routes.py b/app/user/routes.py index bbaa1444..91ba8cb7 100644 --- a/app/user/routes.py +++ b/app/user/routes.py @@ -79,7 +79,7 @@ def show_profile(user): description=description, subscribed=subscribed, upvoted=upvoted, post_next_url=post_next_url, post_prev_url=post_prev_url, replies_next_url=replies_next_url, replies_prev_url=replies_prev_url, - noindex=not user.indexable, + noindex=not user.indexable, show_post_community=True, moderating_communities=moderating_communities(current_user.get_id()), joined_communities=joined_communities(current_user.get_id()) )