Ticket #10677: 10677.diff

File 10677.diff, 3.8 KB (added by Thejaswi Puthraya, 15 years ago)

git-patch against the latest checkout

  • django/contrib/comments/moderation.py

    diff --git a/django/contrib/comments/moderation.py b/django/contrib/comments/moderation.py
    index 9dd6e54..48e39c7 100644
    a b import datetime  
    6666
    6767from django.conf import settings
    6868from django.core.mail import send_mail
    69 from django.db.models import signals
     69from django.contrib.comments import signals
    7070from django.db.models.base import ModelBase
    7171from django.template import Context, loader
    7272from django.contrib import comments
    class Moderator(object):  
    341341        from the comment models.
    342342
    343343        """
    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())
    346346
    347347    def register(self, model_or_iterable, moderation_class):
    348348        """
    class Moderator(object):  
    376376                raise NotModerated("The model '%s' is not currently being moderated" % model._meta.module_name)
    377377            del self._registry[model]
    378378
    379     def pre_save_moderation(self, sender, instance, **kwargs):
     379    def pre_save_moderation(self, sender, **kwargs):
    380380        """
    381381        Apply any necessary pre-save moderation steps to new
    382382        comments.
    383383
    384384        """
     385        instance = kwargs['comment']
    385386        model = instance.content_type.model_class()
    386387        if instance.id or (model not in self._registry):
    387388            return
    class Moderator(object):  
    393394        if moderation_class.moderate(instance, content_object):
    394395            instance.is_public = False
    395396
    396     def post_save_moderation(self, sender, instance, **kwargs):
     397    def post_save_moderation(self, sender, **kwargs):
    397398        """
    398399        Apply any necessary post-save moderation steps to new
    399400        comments.
    400401
    401402        """
     403        instance = kwargs['comment']
    402404        model = instance.content_type.model_class()
    403405        if model not in self._registry:
    404406            return
  • django/contrib/comments/views/comments.py

    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):  
    109109        comment = comment,
    110110        request = request
    111111    )
    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)
    113116    return next_redirect(data, next, comment_done, c=comment._get_pk_val())
    114117
    115118post_comment = require_POST(post_comment)
  • docs/ref/contrib/comments/moderation.txt

    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.  
    221221        and :data:`~django.db.models.signals.post_save` signals from the
    222222        comment models.
    223223
    224     .. method:: pre_save_moderation(sender, instance, **kwargs)
     224    .. method:: pre_save_moderation(sender, **kwargs)
    225225
    226226        In the base implementation, applies all pre-save moderation
    227227        steps (such as determining whether the comment needs to be
    228228        deleted, or whether it needs to be marked as non-public or
    229229        generate an email).
    230230
    231     .. method:: post_save_moderation(sender, instance, **kwargs)
     231    .. method:: post_save_moderation(sender, **kwargs)
    232232
    233233        In the base implementation, applies all post-save moderation
    234234        steps (currently this consists entirely of deleting comments
Back to Top