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

publish_or_unpublish_nested_comments intended behavior #196

Closed rgutierrez-cotech closed 4 years ago

rgutierrez-cotech commented 4 years ago

I had a question about this publish_or_unpublish_nested_comments signal.

I noticed that it is not firing when I save a comment object with is_removed=True and is_public=False, though I am using a hacked-together API of my own to create and delete comments. I am doing django_comments_xtd.get_model() to get the comment model, then setting is_removed and is_public and finally saving the instance. I am using a custom comments model in my application that extends XtdComment so that is what is getting returned on get_model(). But the signal is hard-coded to accept XtdComment as the sender. Should the sender instead be the result of django_comments_xtd.get_model()? Or am I misunderstanding the signal? Should I just use XtdComment instead?

The multi-table inheritance thing still takes me a second to understand so I might be missing something

danirus commented 4 years ago

I think it's a bug in the receiver function in django-comments-xtd. The receiver should use the model as registered in COMMENTS_XTD_MODEL, but transformed in the app_label.model form.

You could try to fix it in your own fork by adding the receiver function to your own models.py, the one you point to with COMMENTS_XTD_MODEL. And replacing the sender with your model class.

Let me know if that fix the problem.

danirus commented 4 years ago

@rgutierrez-cotech, feel free to reopen the issue if you still find issues. I will pack the changes done in the PR #198 in the next release v2.7.1. Meanwhile they are available in master.

rgutierrez-cotech commented 4 years ago

That did the trick, thank you!