summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorJacob Kaplan-Moss <jacob@jacobian.org>2008-08-26 18:53:52 +0000
committerJacob Kaplan-Moss <jacob@jacobian.org>2008-08-26 18:53:52 +0000
commit378f5ddb5acb919525002fd92ff249f103ea8f31 (patch)
treefe1eba8fe0b912a7d374859d264551fd84bff764 /django
parentc6a2bd9b962af1cdf46f964589e6023046cfa8ec (diff)
Updated comment signals to provide enough information to actually act on. This was uncovered when working on the documentation, which'll be committed shortly.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@8589 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django')
-rw-r--r--django/contrib/comments/signals.py6
-rw-r--r--django/contrib/comments/views/comments.py12
-rw-r--r--django/contrib/comments/views/moderation.py24
3 files changed, 34 insertions, 8 deletions
diff --git a/django/contrib/comments/signals.py b/django/contrib/comments/signals.py
index 346a2e0449..fe1083bd14 100644
--- a/django/contrib/comments/signals.py
+++ b/django/contrib/comments/signals.py
@@ -9,13 +9,13 @@ from django.dispatch import Signal
# discarded and a 403 (not allowed) response. This signal is sent at more or less
# the same time (just before, actually) as the Comment object's pre-save signal,
# except that the HTTP request is sent along with this signal.
-comment_will_be_posted = Signal()
+comment_will_be_posted = Signal(providing_args=["comment", "request"])
# Sent just after a comment was posted. See above for how this differs
# from the Comment object's post-save signal.
-comment_was_posted = Signal()
+comment_was_posted = Signal(providing_args=["comment", "request"])
# Sent after a comment was "flagged" in some way. Check the flag to see if this
# was a user requesting removal of a comment, a moderator approving/removing a
# comment, or some other custom user flag.
-comment_was_flagged = Signal()
+comment_was_flagged = Signal(providing_args=["comment", "flag", "created", "request"])
diff --git a/django/contrib/comments/views/comments.py b/django/contrib/comments/views/comments.py
index f8544937d9..e2b544545e 100644
--- a/django/contrib/comments/views/comments.py
+++ b/django/contrib/comments/views/comments.py
@@ -96,7 +96,11 @@ def post_comment(request, next=None):
comment.user = request.user
# Signal that the comment is about to be saved
- responses = signals.comment_will_be_posted.send(comment)
+ responses = signals.comment_will_be_posted.send(
+ sender = comment.__class__,
+ comment = comment,
+ request = request
+ )
for (receiver, response) in responses:
if response == False:
@@ -105,7 +109,11 @@ def post_comment(request, next=None):
# Save the comment and signal that it was saved
comment.save()
- signals.comment_was_posted.send(comment)
+ signals.comment_was_posted.send(
+ sender = comment.__class__,
+ comment = comment,
+ request = request
+ )
return next_redirect(data, next, comment_done, c=comment._get_pk_val())
diff --git a/django/contrib/comments/views/moderation.py b/django/contrib/comments/views/moderation.py
index 0600b5fe08..3334b0927e 100644
--- a/django/contrib/comments/views/moderation.py
+++ b/django/contrib/comments/views/moderation.py
@@ -27,7 +27,13 @@ def flag(request, comment_id, next=None):
user = request.user,
flag = comments.models.CommentFlag.SUGGEST_REMOVAL
)
- signals.comment_was_flagged.send(comment)
+ signals.comment_was_flagged.send(
+ sender = comment.__class__,
+ comment = comment,
+ flag = flag,
+ created = created,
+ request = request,
+ )
return next_redirect(request.POST.copy(), next, flag_done, c=comment.pk)
# Render a form on GET
@@ -61,7 +67,13 @@ def delete(request, comment_id, next=None):
)
comment.is_removed = True
comment.save()
- signals.comment_was_flagged.send(comment)
+ signals.comment_was_flagged.send(
+ sender = comment.__class__,
+ comment = comment,
+ flag = flag,
+ created = created,
+ request = request,
+ )
return next_redirect(request.POST.copy(), next, delete_done, c=comment.pk)
# Render a form on GET
@@ -98,7 +110,13 @@ def approve(request, comment_id, next=None):
comment.is_public = True
comment.save()
- signals.comment_was_flagged.send(comment)
+ signals.comment_was_flagged.send(
+ sender = comment.__class__,
+ comment = comment,
+ flag = flag,
+ created = created,
+ request = request,
+ )
return next_redirect(request.POST.copy(), next, approve_done, c=comment.pk)
# Render a form on GET