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
595 stars 158 forks source link

Ability to delete own comment #361

Open sabyasachi opened 2 years ago

sabyasachi commented 2 years ago

Creating a separate ticket as discussed in https://github.com/danirus/django-comments-xtd/issues/162.

Users should be able to delete their own comments.

Any workaround till then?

danirus commented 2 years ago

Thanks @sabyasachi.

An initial description of the user story could be:

  1. Enable comment deletion by setting COMMENTS_XTD_ALLOW_COMMENT_DELETION = True.
  2. Add a "Delete" link in the footer of the comment.
  3. Create a remove.html and removed.html templates. They will be used when not using the JavaScript plugin.
  4. The comment object will not be remove from the DB, as that would break the comment tree, but rather marked as removed by setting the is_removed attribute of the comment to True.
  5. It should be possible to connect to a new signal comment_removal_received to allow other apps do something additional when the a user sends a comment removal: maybe deleting the content of the comment attribute, or whatnot. So that signal must be sent within the user-request-comment-removal controller.
  6. If the user is authenticated, and the comment.user matches the authenticated user, the remove.html template will display a confirmation button to remove the comment. Once the user clicks the button, the removed.html template will confirm the user that comment has been removed.
  7. If the user is not authenticated the remove.html template should request the user to provide the email used to post the comment. In the controller, if the email provided doesn't match the comment's user_email attribute, it should simply ignore the request, but will inform the user that a confirmation email has been sent. The confirmation email shall be requested only when the email address provided by the user matches the comment's user_email.
  8. Add the required routes to the urlpatterns.
  9. There should be an implementation of this logic in the JavaScript plugin.

Let me know if I missed anything important. We could go further in detail. That's just a bullet point description of what shall be done. If anyone feels like working on it, please, feel free to ask. Otherwise I will do it sometime in the future.

callmeUmer commented 2 years ago

@danirus Is this issue still open ? if yes, I can definitely work on this.

danirus commented 2 years ago

Sounds good @callmeUmer. I assign it to you. Feel free to reach out here or by email (it is in my commits).