danirus / django-comments-xtd

A pluggable Django comments application with thread support, follow-up notifications, mail confirmation, like/dislike flags, moderation, a ReactJS plugin and Bootstrap 5.3.
https://django-comments-xtd.readthedocs.io
BSD 2-Clause "Simplified" License
594 stars 158 forks source link

COMMENTS_HIDE_REMOVED seems to not be used (honored) #194

Open jimkring opened 4 years ago

jimkring commented 4 years ago

In the docs for Django Comments, it describes the settings.

COMMENTS_HIDE_REMOVE If True (default), removed comments will be excluded from comment lists/counts (as taken from template tags). Otherwise, the template author is responsible for some sort of a “this comment has been removed by the site staff” message.

I've tried applying this setting and the {% render_xtdcomment_tree for object %} tag returning all the comments, even ones that have an is_removed value of True, which then requires these to be manually filtered them in the template. That's not the end of the world, but figured I'd mention it.

danirus commented 4 years ago

Thanks for the report! It's been there since the beginning of this application.

rgutierrez-cotech commented 4 years ago

I was able to sorta get around this by just adding is_removed=False to the queryset in the template tag before XtdComment.tree_from_queryset() is called. But there seems to be a side-effect to doing that. Any replies to comments that are marked removed still show up in the tree, e.g. if Comment B is a reply to Comment A and Comment A is marked removed, Comment B will still show up in the tree.

Filtering by is_removed within the loop in the template seems to also work, which is what I assume @jimkring was doing (or at least something similar):

{% for item in comments %}
    {% if not item.comment.is_removed %}
        . . .
jimkring commented 4 years ago

@rgutierrez-cotech yes, I was filtering by is_removed within the loop, inside the template. That works well for my needs, yet it would be nice if that filtering were possible at a deeper level in the application. A nice aspect of having the removed items filtered manually, is that they can be shown to admins who can reverse the removal, if needed (in case a comment was accidentally removed).

danirus commented 4 years ago

This app has always ignored django-comments' COMMENTS_HIDE_REMOVED setting. The default value of that setting is True, therefore fixing django-comments-xtd to take into account the value of COMMENTS_HIDE_REMOVED will break backwards compatibility. So the fix for this issue will force a change in the major version number.