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.
This commit is contained in:
parent
619aca286a
commit
e67178abdb
3 changed files with 12 additions and 5 deletions
|
|
@ -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."""
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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)))) %}
|
||||
<div id="comment-{{ comment.id }}" class="comment{% if comment.parent_id %} reply{% endif %}" style="margin-left: {{ comment.depth * 20 }}px;{% if comment.parent_id %} border-left: 2px solid #ddd; padding-left: 10px;{% endif %}">
|
||||
<div id="comment-{{ comment.id }}" class="comment{% if comment.parent_id %} reply{% endif %}" style="margin-left: {{ comment.depth * 20 }}px; margin-bottom: 20px;{% if comment.parent_id %} border-left: 2px solid #ddd; padding-left: 10px;{% endif %}">
|
||||
<div class="comment-header">
|
||||
<strong>{{ comment.user.name if comment.user else "Anonymous" }}</strong>
|
||||
<span class="comment-date">{{ comment.ago_string }}</span>
|
||||
|
|
@ -45,8 +45,8 @@
|
|||
{% endif %}
|
||||
</div>
|
||||
|
||||
{% 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 @@
|
|||
</div>
|
||||
|
||||
<div>
|
||||
<input type="submit" value="Post Comment" class="mps-submit" />
|
||||
<input type="submit" value="Post Comment" />
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue