From a2fae00936cedec26d55ad2ad95ab1993ee7a819 Mon Sep 17 00:00:00 2001 From: freamon Date: Fri, 18 Oct 2024 08:35:32 +0000 Subject: [PATCH] post-reply soft-deletion: replace content in HTML with 'deleted by author/moderator' --- app/post/util.py | 4 ++-- app/templates/post/continue_discussion.html | 10 +++++++++- app/templates/post/post.html | 10 +++++++++- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/app/post/util.py b/app/post/util.py index f904abb3..3eddaedf 100644 --- a/app/post/util.py +++ b/app/post/util.py @@ -11,7 +11,7 @@ from app.utils import blocked_instances, blocked_users # replies to a post, in a tree, sorted by a variety of methods def post_replies(post_id: int, sort_by: str, show_first: int = 0) -> List[PostReply]: - comments = PostReply.query.filter_by(post_id=post_id).filter(PostReply.deleted == False) + comments = PostReply.query.filter_by(post_id=post_id) if current_user.is_authenticated: instance_ids = blocked_instances(current_user.id) if instance_ids: @@ -52,7 +52,7 @@ def get_comment_branch(post_id: int, comment_id: int, sort_by: str) -> List[Post if parent_comment is None: return [] - comments = PostReply.query.filter(PostReply.post_id == post_id, PostReply.deleted == False) + comments = PostReply.query.filter(PostReply.post_id == post_id) if current_user.is_authenticated: instance_ids = blocked_instances(current_user.id) if instance_ids: diff --git a/app/templates/post/continue_discussion.html b/app/templates/post/continue_discussion.html index a30f11a6..bda80148 100644 --- a/app/templates/post/continue_discussion.html +++ b/app/templates/post/continue_discussion.html @@ -28,7 +28,15 @@ {% endif %}
- {{ comment['comment'].body_html | safe }} + {% if comment['comment'].deleted -%} + {% if comment['comment'].deleted_by is none or comment['comment'].deleted_by != comment['comment'].user_id -%} +

Deleted by moderator

+ {% else -%} +

Deleted by author

+ {% endif -%} + {% else -%} + {{ comment['comment'].body_html | community_links | safe }} + {% endif -%}
diff --git a/app/templates/post/post.html b/app/templates/post/post.html index 1e9fa6c2..a6137b1b 100644 --- a/app/templates/post/post.html +++ b/app/templates/post/post.html @@ -91,7 +91,15 @@ {% endif -%}
- {{ comment['comment'].body_html | community_links | safe }} + {% if comment['comment'].deleted -%} + {% if comment['comment'].deleted_by is none or comment['comment'].deleted_by != comment['comment'].user_id -%} +

Deleted by moderator

+ {% else -%} +

Deleted by author

+ {% endif -%} + {% else -%} + {{ comment['comment'].body_html | community_links | safe }} + {% endif -%}
{% if not comment['comment'].author.indexable -%}{% endif -%}