soft deletes - home page #193

This commit is contained in:
rimu 2024-06-02 19:09:57 +12:00
parent 2380a3ae61
commit 07d52ae54e

View file

@ -85,17 +85,17 @@ def home_page(type, sort):
else: else:
if type == 'home': if type == 'home':
posts = Post.query.join(CommunityMember, Post.community_id == CommunityMember.community_id).filter( posts = Post.query.join(CommunityMember, Post.community_id == CommunityMember.community_id).filter(
CommunityMember.is_banned == False) CommunityMember.is_banned == False, Post.deleted == False)
# posts = posts.join(User, CommunityMember.user_id == User.id).filter(User.id == current_user.id) # posts = posts.join(User, CommunityMember.user_id == User.id).filter(User.id == current_user.id)
posts = posts.filter(CommunityMember.user_id == current_user.id) posts = posts.filter(CommunityMember.user_id == current_user.id)
elif type == 'popular': elif type == 'popular':
posts = Post.query.filter(Post.from_bot == False) posts = Post.query.filter(Post.from_bot == False)
posts = posts.join(Community, Community.id == Post.community_id) posts = posts.join(Community, Community.id == Post.community_id)
posts = posts.filter(Community.show_popular == True, Post.score > 100) posts = posts.filter(Community.show_popular == True, Post.score > 100, Post.deleted == False)
elif type == 'all': elif type == 'all':
posts = Post.query posts = Post.query
posts = posts.join(Community, Community.id == Post.community_id) posts = posts.join(Community, Community.id == Post.community_id)
posts = posts.filter(Community.show_all == True) posts = posts.filter(Community.show_all == True, Post.deleted == False)
if current_user.ignore_bots: if current_user.ignore_bots:
posts = posts.filter(Post.from_bot == False) posts = posts.filter(Post.from_bot == False)