signals.txt 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. .. _ref-contrib-comments-signals:
  2. ================================
  3. Signals sent by the comments app
  4. ================================
  5. .. module:: django.contrib.comments.signals
  6. :synopsis: Signals sent by the comment module.
  7. The comment app sends a series of :ref:`signals <topics-signals>` to allow for
  8. comment moderation and similar activities. See :ref:`the introduction to signals
  9. <topics-signals>` for information about how to register for and receive these
  10. signals.
  11. comment_will_be_posted
  12. ======================
  13. .. data:: django.contrib.comments.signals.comment_will_be_posted
  14. :module:
  15. Sent just before a comment will be saved, after it's been sanity checked and
  16. submitted. This can be used to modify the comment (in place) with posting
  17. details or other such actions.
  18. If any receiver returns ``False`` the comment will be discarded and a 403 (not
  19. allowed) response will be returned.
  20. This signal is sent at more or less the same time (just before, actually) as the
  21. ``Comment`` object's :data:`~django.db.models.signals.pre_save` signal.
  22. Arguments sent with this signal:
  23. ``sender``
  24. The comment model.
  25. ``comment``
  26. The comment instance about to be posted. Note that it won't have been
  27. saved into the database yet, so it won't have a primary key, and any
  28. relations might not work correctly yet.
  29. ``request``
  30. The :class:`~django.http.HttpRequest` that posted the comment.
  31. comment_was_posted
  32. ==================
  33. .. data:: django.contrib.comments.signals.comment_was_posted
  34. :module:
  35. Sent just after the comment is saved.
  36. Arguments sent with this signal:
  37. ``sender``
  38. The comment model.
  39. ``comment``
  40. The comment instance that was posted. Note that it will have already
  41. been saved, so if you modify it you'll need to call
  42. :meth:`~django.db.models.Model.save` again.
  43. ``request``
  44. The :class:`~django.http.HttpRequest` that posted the comment.
  45. comment_was_flagged
  46. ===================
  47. .. data:: django.contrib.comments.signals.comment_was_flagged
  48. :module:
  49. Sent after a comment was "flagged" in some way. Check the flag to see if this
  50. was a user requesting removal of a comment, a moderator approving/removing a
  51. comment, or some other custom user flag.
  52. Arguments sent with this signal:
  53. ``sender``
  54. The comment model.
  55. ``comment``
  56. The comment instance that was posted. Note that it will have already
  57. been saved, so if you modify it you'll need to call
  58. :meth:`~django.db.models.Model.save` again.
  59. ``flag``
  60. The :class:`~django.contrib.comments.models.CommentFlag` that's been
  61. attached to the comment.
  62. ``created``
  63. ``True`` if this is a new flag; ``False`` if it's a duplicate flag.
  64. ``request``
  65. The :class:`~django.http.HttpRequest` that posted the comment.