Skip to content

Commit

Permalink
fix: Show correct comment tree in object detail
Browse files Browse the repository at this point in the history
  • Loading branch information
mireq committed Apr 20, 2024
1 parent 51bd529 commit b1bad42
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions comments/admin.py
@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-
from attachment.admin import AttachmentInline, AttachmentAdminMixin
from common_utils.admin import render_tree_depth
from common_utils.models import TreeDepth
from django.contrib import admin
from django.contrib.contenttypes.admin import GenericTabularInline
Expand Down Expand Up @@ -122,13 +123,13 @@ class CommentInline(GenericTabularInline):
extra = 0

def get_queryset(self, request):
return super().get_queryset(request).order_by('lft')
return (super().get_queryset(request)
.order_siblings_by('pk')
.annotate(tree_depth=TreeDepth())
)

def get_subject(self, obj):
indent = ''
if obj.tree_depth:
indent = mark_safe('  ' * (obj.tree_depth-1))
return format_html("{}{}", indent, obj.subject)
return format_html("{}{}", render_tree_depth(obj), obj.subject)
get_subject.short_description = "Predmet"


Expand Down

0 comments on commit b1bad42

Please sign in to comment.