From 779def72aad13b92e964287fcfb4029b200797a4 Mon Sep 17 00:00:00 2001 From: Alan Roberts Date: Sun, 29 Sep 2024 14:02:29 -0400 Subject: [PATCH] adding read-posts filtering to domain page --- app/domain/routes.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app/domain/routes.py b/app/domain/routes.py index cd5adade..d04828bc 100644 --- a/app/domain/routes.py +++ b/app/domain/routes.py @@ -38,6 +38,16 @@ def show_domain(domain_id): content_filters = user_filters_posts(current_user.id) else: content_filters = {} + + # don't show posts a user has already interacted with + if current_user.hide_read_posts: + cu_rp = current_user.read_post.all() + cu_rp_ids = [] + for p in cu_rp: + cu_rp_ids.append(p.id) + for p_id in cu_rp_ids: + posts = posts.filter(Post.id != p_id) + # pagination posts = posts.paginate(page=page, per_page=100, error_out=False) next_url = url_for('domain.show_domain', domain_id=domain_id, page=posts.next_num) if posts.has_next else None