mirror of
https://codeberg.org/rimu/pyfedi
synced 2025-01-23 11:26:56 -08:00
ban people from community, and unban them - topics and search #21
This commit is contained in:
parent
9fd4ac1c53
commit
1a8c21670e
3 changed files with 12 additions and 4 deletions
|
@ -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)
|
||||
|
|
|
@ -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/<path:topic_path>', 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':
|
||||
|
|
|
@ -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())
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue