honzakral / django-threadedcomments

django-threadedcomments is a simple yet flexible threaded commenting system for Django.
BSD 3-Clause "New" or "Revised" License
622 stars 165 forks source link

Unexpected tree when there are deleted comments #102

Open tisdall opened 5 years ago

tisdall commented 5 years ago

Note: It seems that if you run with COMMENTS_HIDE_REMOVED = False then things work correctly, but the default is True. (well, except for #97, but that can be fixed in the templates)

Let's say you have the following comment tree:

If you delete the "second" comment it then renders like this:

This is a problem because the "third" comment is a reply to "second" but now it looks like it's a reply to "first". All other replies to "second" are also moved up like this too.

Even worse, if you submit another reply to the "first" comment you then get the following:

If you look in the database you can confirm that "reply to first" has the proper tree_path and parent_id. Any further comments on "first" appear below and at the same level as "reply to first".

If you then delete the "first" comment you'll then get this:

Both "first" and "second" are actually properly marked as is_removed so a fix for #97 in the template would mean the deleted ones would be rendered as "deleted" or something like that. In the example before this one, the "second" comment isn't even in the tree so it can't be handled in the template.

EDIT: I should clarify that I'm using django_comments.views.moderation.perform_delete to "delete" the ThreadedComment object (ie it's marking it as is_removed=True and not actually deleting).