diff --git a/django/contrib/comments/moderation.py b/django/contrib/comments/moderation.py
index 9dd6e54..48e39c7 100644
a
|
b
|
import datetime
|
66 | 66 | |
67 | 67 | from django.conf import settings |
68 | 68 | from django.core.mail import send_mail |
69 | | from django.db.models import signals |
| 69 | from django.contrib.comments import signals |
70 | 70 | from django.db.models.base import ModelBase |
71 | 71 | from django.template import Context, loader |
72 | 72 | from django.contrib import comments |
… |
… |
class Moderator(object):
|
341 | 341 | from the comment models. |
342 | 342 | |
343 | 343 | """ |
344 | | signals.pre_save.connect(self.pre_save_moderation, sender=comments.get_model()) |
345 | | signals.post_save.connect(self.post_save_moderation, sender=comments.get_model()) |
| 344 | signals.comment_will_be_posted.connect(self.pre_save_moderation, sender=comments.get_model()) |
| 345 | signals.comment_was_posted.connect(self.post_save_moderation, sender=comments.get_model()) |
346 | 346 | |
347 | 347 | def register(self, model_or_iterable, moderation_class): |
348 | 348 | """ |
… |
… |
class Moderator(object):
|
376 | 376 | raise NotModerated("The model '%s' is not currently being moderated" % model._meta.module_name) |
377 | 377 | del self._registry[model] |
378 | 378 | |
379 | | def pre_save_moderation(self, sender, instance, **kwargs): |
| 379 | def pre_save_moderation(self, sender, **kwargs): |
380 | 380 | """ |
381 | 381 | Apply any necessary pre-save moderation steps to new |
382 | 382 | comments. |
383 | 383 | |
384 | 384 | """ |
| 385 | instance = kwargs['comment'] |
385 | 386 | model = instance.content_type.model_class() |
386 | 387 | if instance.id or (model not in self._registry): |
387 | 388 | return |
… |
… |
class Moderator(object):
|
393 | 394 | if moderation_class.moderate(instance, content_object): |
394 | 395 | instance.is_public = False |
395 | 396 | |
396 | | def post_save_moderation(self, sender, instance, **kwargs): |
| 397 | def post_save_moderation(self, sender, **kwargs): |
397 | 398 | """ |
398 | 399 | Apply any necessary post-save moderation steps to new |
399 | 400 | comments. |
400 | 401 | |
401 | 402 | """ |
| 403 | instance = kwargs['comment'] |
402 | 404 | model = instance.content_type.model_class() |
403 | 405 | if model not in self._registry: |
404 | 406 | return |
diff --git a/django/contrib/comments/views/comments.py b/django/contrib/comments/views/comments.py
index 3279543..587c5e9 100644
a
|
b
|
def post_comment(request, next=None):
|
109 | 109 | comment = comment, |
110 | 110 | request = request |
111 | 111 | ) |
112 | | |
| 112 | if not comment._get_pk_val(): |
| 113 | # If comment was deleted by any of the |
| 114 | # signal handlers. |
| 115 | return next_redirect(data, next, comment_done) |
113 | 116 | return next_redirect(data, next, comment_done, c=comment._get_pk_val()) |
114 | 117 | |
115 | 118 | post_comment = require_POST(post_comment) |
diff --git a/docs/ref/contrib/comments/moderation.txt b/docs/ref/contrib/comments/moderation.txt
index 545279b..a717fe7 100644
a
|
b
|
models with an instance of the subclass.
|
221 | 221 | and :data:`~django.db.models.signals.post_save` signals from the |
222 | 222 | comment models. |
223 | 223 | |
224 | | .. method:: pre_save_moderation(sender, instance, **kwargs) |
| 224 | .. method:: pre_save_moderation(sender, **kwargs) |
225 | 225 | |
226 | 226 | In the base implementation, applies all pre-save moderation |
227 | 227 | steps (such as determining whether the comment needs to be |
228 | 228 | deleted, or whether it needs to be marked as non-public or |
229 | 229 | generate an email). |
230 | 230 | |
231 | | .. method:: post_save_moderation(sender, instance, **kwargs) |
| 231 | .. method:: post_save_moderation(sender, **kwargs) |
232 | 232 | |
233 | 233 | In the base implementation, applies all post-save moderation |
234 | 234 | steps (currently this consists entirely of deleting comments |