From 9a033522d1a146eb9299e4de4e74a8cbff9f5910 Mon Sep 17 00:00:00 2001 From: freamon Date: Fri, 25 Oct 2024 21:55:19 +0000 Subject: [PATCH] post soft-deletion: show deleted posts in user profile to provide restoration route --- app/templates/post/post_teaser/_article.html | 1 + app/templates/post/post_teaser/_image.html | 1 + app/templates/post/post_teaser/_link.html | 1 + app/templates/post/post_teaser/_poll.html | 1 + app/templates/post/post_teaser/_video.html | 1 + app/user/routes.py | 4 +++- 6 files changed, 8 insertions(+), 1 deletion(-) diff --git a/app/templates/post/post_teaser/_article.html b/app/templates/post/post_teaser/_article.html index 149dfa95..6377640e 100644 --- a/app/templates/post/post_teaser/_article.html +++ b/app/templates/post/post_teaser/_article.html @@ -6,6 +6,7 @@ {% endif -%} {% if post.sticky -%}{% endif -%} + {% if post.deleted -%}{% endif -%} {% if show_post_community -%} {% if post.community.icon_id and not low_bandwidth %}Community icon{% endif -%} diff --git a/app/templates/post/post_teaser/_image.html b/app/templates/post/post_teaser/_image.html index 728f58c3..15ee255b 100644 --- a/app/templates/post/post_teaser/_image.html +++ b/app/templates/post/post_teaser/_image.html @@ -9,6 +9,7 @@ {% endif -%} {% if post.sticky -%}{% endif -%} + {% if post.deleted -%}{% endif -%} {% if show_post_community -%} {% if post.community.icon_id and not low_bandwidth %}Community icon{% endif -%} diff --git a/app/templates/post/post_teaser/_link.html b/app/templates/post/post_teaser/_link.html index 45ef98c6..52c139d1 100644 --- a/app/templates/post/post_teaser/_link.html +++ b/app/templates/post/post_teaser/_link.html @@ -12,6 +12,7 @@ {% endif -%} {% if post.sticky -%}{% endif -%} + {% if post.deleted -%}{% endif -%} {% if show_post_community -%} {% if post.community.icon_id and not low_bandwidth %}Community icon{% endif -%} diff --git a/app/templates/post/post_teaser/_poll.html b/app/templates/post/post_teaser/_poll.html index bfb740ae..5d0c8542 100644 --- a/app/templates/post/post_teaser/_poll.html +++ b/app/templates/post/post_teaser/_poll.html @@ -7,6 +7,7 @@ {% endif -%} {% if post.sticky -%}{% endif -%} + {% if post.deleted -%}{% endif -%} {% if show_post_community -%} {% if post.community.icon_id and not low_bandwidth %}Community icon{% endif -%} diff --git a/app/templates/post/post_teaser/_video.html b/app/templates/post/post_teaser/_video.html index f93b3d84..821df3de 100644 --- a/app/templates/post/post_teaser/_video.html +++ b/app/templates/post/post_teaser/_video.html @@ -14,6 +14,7 @@ {% endif -%} {% if post.sticky -%}{% endif -%} + {% if post.deleted -%}{% endif -%} {% if show_post_community -%} {% if post.community.icon_id and not low_bandwidth %}Community icon{% endif -%} diff --git a/app/user/routes.py b/app/user/routes.py index 2be82cf8..5753f783 100644 --- a/app/user/routes.py +++ b/app/user/routes.py @@ -55,7 +55,6 @@ def show_profile(user): post_page = request.args.get('post_page', 1, type=int) replies_page = request.args.get('replies_page', 1, type=int) - posts = Post.query.filter_by(user_id=user.id).filter(Post.deleted == False).order_by(desc(Post.posted_at)).paginate(page=post_page, per_page=50, error_out=False) moderates = Community.query.filter_by(banned=False).join(CommunityMember).filter(CommunityMember.user_id == user.id)\ .filter(or_(CommunityMember.is_moderator, CommunityMember.is_owner)) if current_user.is_authenticated and (user.id == current_user.get_id() or current_user.is_admin()): @@ -65,10 +64,13 @@ def show_profile(user): subscribed = Community.query.filter_by(banned=False).join(CommunityMember).filter(CommunityMember.user_id == user.id).all() if current_user.is_anonymous or (user.id != current_user.id and not current_user.is_admin()): moderates = moderates.filter(Community.private_mods == False) + posts = Post.query.filter_by(user_id=user.id).filter(Post.deleted == False).order_by(desc(Post.posted_at)).paginate(page=post_page, per_page=50, error_out=False) post_replies = PostReply.query.filter_by(user_id=user.id, deleted=False).order_by(desc(PostReply.posted_at)).paginate(page=replies_page, per_page=50, error_out=False) elif current_user.is_admin(): + posts = Post.query.filter_by(user_id=user.id).order_by(desc(Post.posted_at)).paginate(page=post_page, per_page=50, error_out=False) post_replies = PostReply.query.filter_by(user_id=user.id).order_by(desc(PostReply.posted_at)).paginate(page=replies_page, per_page=50, error_out=False) elif current_user.id == user.id: + posts = Post.query.filter_by(user_id=user.id).filter(or_(Post.deleted == False, Post.deleted_by == user.id)).order_by(desc(Post.posted_at)).paginate(page=post_page, per_page=50, error_out=False) post_replies = PostReply.query.filter_by(user_id=user.id).filter(or_(PostReply.deleted == False, PostReply.deleted_by == user.id)).order_by(desc(PostReply.posted_at)).paginate(page=replies_page, per_page=50, error_out=False) # profile info