1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 | from django.contrib.sites.models import Site
from django.template import Context, loader
from comment_utils.moderation import CommentModerator
class EmailOwner(CommentModerator):
"""
Subclass of ``CommentModerator`` which emails the "owner" of an
object whenever a new comment is posted on it.
Assumes that the 'owner' is specified by a ``ForeignKey`` named
'user'; edit that if your field is named something else.
"""
email_notification = True
def email(self, comment, content_object):
t = loader.get_template('comment_email_owner.txt')
c = Context({ 'comment': comment,
'content_object': content_object })
subject = '[%s] New comment posted on "%s"' % (Site.objects.get_current().name,
content_object)
message = t.render(c)
send_mail(subject, message, settings.DEFAULT_FROM_EMAIL,
[content_object.user.email], fail_silently=True)
|
Comments
What is this polymorphism you speak of? :)
#