Ticket #12018: comments_request_context2.diff

File comments_request_context2.diff, 2.4 KB (added by Adam Vandenberg, 14 years ago)
  • django/contrib/comments/moderation.py

    diff --git a/django/contrib/comments/moderation.py b/django/contrib/comments/moderation.py
    index 17d61da..358ab47 100644
    a b from django.conf import settings  
    6060from django.core.mail import send_mail
    6161from django.contrib.comments import signals
    6262from django.db.models.base import ModelBase
    63 from django.template import Context, loader
     63from django.template import RequestContext, loader
    6464from django.contrib import comments
    6565from django.contrib.sites.models import Site
    6666
    class CommentModerator(object):  
    227227                return True
    228228        return False
    229229
    230     def email(self, comment, content_object, request):
     230    def email(self, comment, content_object, request, extra_context=None):
    231231        """
    232232        Send email notification of a new comment to site staff when email
    233233        notifications have been requested.
    class CommentModerator(object):  
    237237            return
    238238        recipient_list = [manager_tuple[1] for manager_tuple in settings.MANAGERS]
    239239        t = loader.get_template('comments/comment_notification_email.txt')
    240         c = Context({ 'comment': comment,
    241                       'content_object': content_object })
     240
     241        context = { 'comment': comment, 'content_object': content_object }
     242        context.update(extra_context or {})
    242243        subject = '[%s] New comment posted on "%s"' % (Site.objects.get_current().name,
    243244                                                          content_object)
    244         message = t.render(c)
     245        message = t.render(RequestContext(context))
    245246        send_mail(subject, message, settings.DEFAULT_FROM_EMAIL, recipient_list, fail_silently=True)
    246247
    247248class Moderator(object):
  • docs/ref/contrib/comments/moderation.txt

    diff --git a/docs/ref/contrib/comments/moderation.txt b/docs/ref/contrib/comments/moderation.txt
    index 4f4b326..2329bd0 100644
    a b object the comment will be attached to, and ``request``, which is the  
    159159    post on the content object, and ``False`` otherwise (in which
    160160    case the comment will be immediately deleted).
    161161
    162 .. method:: CommentModerator.email(comment, content_object, request)
     162.. method:: CommentModerator.email(comment, content_object, request, extra_context=None)
    163163
    164164    If email notification of the new comment should be sent to
    165165    site staff or moderators, this method is responsible for
Back to Top