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

Object Likes and Email Notifications #190

Open jimkring opened 4 years ago

jimkring commented 4 years ago

It would be nice if the django-comments-xtd could support liking and notifications on the actual "object" itself (for example: the django object that is the target of all the comments).

My use case is this >> if I have a blog post (I'll use "blog post" as an example object) and want it to receive comments, I would also like the author of the blog post to be able to get notification emails about new comments on the post. Also, it would be nice to track the likes received by the blog post -- it seems natural that django-comments-xtd could do this for me, or maybe I could "hack" it to do this.

For example, when a blog post is created, we could automatically create the first comment for the blog post (and assign that comment to the blog posts' author and mark it for notifications). Then, when the comments are rendered, this root-level comment could be filtered out and not displayed.

Anyhow, it's just an idea.

Is there any easy way to achieve what I'm looking for? Notification emails sent to the blog post author anytime a comment is added, and the ability to "like" the blog post itself?

danirus commented 4 years ago

It can't be done with django-comments-xtd. Although it seems a natural case. To send feedback to the author of the story with a simple thumb-up reaction instead of sending a comment. The way models are connected between XtdComment, Comment and CommentFlag doesn't allow it. But with a new model it could be done...

jimkring commented 4 years ago

Thanks @danirus. OK, I'm thinking what I may try is this:

When a new blog post is created, programmatically create the first comment behind the scenes (and set the comment's author to the blog post's author). Then, on the blog post details page slice that first comment off the front of the list of comments {% for item in comments|slice:"1:" %}.

Would you have a quick snippet that you could show me how to programmatically create a first comment for an object and set the user and notification flag? I can dig into the code, yet if you know the answer very quickly of the top of your head, that would get me started much faster :) Thanks!

ashwani99 commented 3 years ago

@jimkring For notification purposes, I think there are better ways to add it inside your Django app. You can easily integrate notification specific libraries like django-notifications or pinax-notifications. You just have to override the comment_was_posted signal receiver with your logic

Also, I feel notifications are something that's closely related to comments but should not be mixed into a library like django-comments-xtd that aims to integrate comments into a Django app