only logged in can filter by Subscribed

This commit is contained in:
rimu 2024-11-30 14:26:22 +13:00
parent 7a7a1fe0d4
commit c74997d49e

View file

@ -91,7 +91,7 @@ def home_page(sort, view_filter):
content_filters = user_filters_home(current_user.id) content_filters = user_filters_home(current_user.id)
# view filter - subscribed/local/all # view filter - subscribed/local/all
if view_filter == 'subscribed': if view_filter == 'subscribed' and current_user.is_authenticated:
posts = posts.join(CommunityMember, Post.community_id == CommunityMember.community_id).filter(CommunityMember.is_banned == False) posts = posts.join(CommunityMember, Post.community_id == CommunityMember.community_id).filter(CommunityMember.is_banned == False)
posts = posts.filter(CommunityMember.user_id == current_user.id) posts = posts.filter(CommunityMember.user_id == current_user.id)
elif view_filter == 'local': elif view_filter == 'local':
@ -102,7 +102,7 @@ def home_page(sort, view_filter):
posts = posts.filter(Community.show_popular == True, Post.score > 100) posts = posts.filter(Community.show_popular == True, Post.score > 100)
if current_user.is_anonymous: if current_user.is_anonymous:
posts = posts.filter(Community.low_quality == False) posts = posts.filter(Community.low_quality == False)
elif view_filter == 'all': elif view_filter == 'all' or current_user.is_anonymous:
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)