From e67178abdbe6b550f46140c0207d04f4950228f3 Mon Sep 17 00:00:00 2001 From: Russell Ballestrini Date: Sat, 4 Oct 2025 10:55:54 -0400 Subject: [PATCH] Fix comment deletion display and improve comment spacing ## Bug Fixes: - **Comment Deletion**: Fixed deleted comments still showing in frontend - Added `enabled_children` property to Comment model to filter disabled comments - Updated template to use `enabled_children` instead of `children` for replies - Ensures soft-deleted comments (and their replies) properly disappear from view ## UI Improvements: - **Comment Spacing**: Added 20px margin-bottom to all comments for better readability - **Form Styling**: Removed unwanted `mps-submit` class from "Post Comment" button - Eliminates `float: right` styling that was misaligning the button ## Technical Details: - Root comments already filtered by database query (`Comment.disabled == False`) - Child comments now properly filtered through `enabled_children` property - Comment deletion uses soft delete (`comment.disable()`) preserving data integrity - Black code formatting applied to maintain style consistency The comment system now properly handles deletions and provides better visual hierarchy. --- make_post_sell/models/comment.py | 5 +++++ make_post_sell/request_methods.py | 4 +++- make_post_sell/templates/snippets/comments.j2 | 8 ++++---- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/make_post_sell/models/comment.py b/make_post_sell/models/comment.py index c7c7c48..38f9d0b 100644 --- a/make_post_sell/models/comment.py +++ b/make_post_sell/models/comment.py @@ -128,6 +128,11 @@ class Comment(RBase, Base): def unverified_children(self): return self.children.filter(Comment.verified == False) + @property + def enabled_children(self): + """Get all non-disabled child comments.""" + return self.children.filter(Comment.disabled == False) + @property def path_to_root(self): """The path from this comment to the root comment.""" diff --git a/make_post_sell/request_methods.py b/make_post_sell/request_methods.py index 1b10ba1..826d1fc 100644 --- a/make_post_sell/request_methods.py +++ b/make_post_sell/request_methods.py @@ -322,7 +322,9 @@ def includeme(config): # Payment method checks config.add_request_method(add_stripe_enabled, "stripe_enabled", reify=True) - config.add_request_method(add_stripe_globally_enabled, "stripe_globally_enabled", reify=True) + config.add_request_method( + add_stripe_globally_enabled, "stripe_globally_enabled", reify=True + ) config.add_request_method(add_monero_enabled, "monero_enabled", reify=True) config.add_request_method( add_monero_rpc_available, "monero_rpc_available", reify=True diff --git a/make_post_sell/templates/snippets/comments.j2 b/make_post_sell/templates/snippets/comments.j2 index 4c859b9..cf37b92 100644 --- a/make_post_sell/templates/snippets/comments.j2 +++ b/make_post_sell/templates/snippets/comments.j2 @@ -1,6 +1,6 @@ {% macro render_comment(comment, shop, request, max_depth=5) %} {% if comment.depth <= max_depth and (comment.approved or (request.user.authenticated and (shop.is_owner(request.user) or shop.is_editor(request.user)))) %} -
+
{{ comment.user.name if comment.user else "Anonymous" }} {{ comment.ago_string }} @@ -45,8 +45,8 @@ {% endif %}
- {% if comment.children %} - {% for child in comment.children %} + {% if comment.enabled_children %} + {% for child in comment.enabled_children %} {{ render_comment(child, shop, request, max_depth) }} {% endfor %} {% endif %} @@ -84,7 +84,7 @@
- +