]> git.sommitrealweird.co.uk Git - sommitrealweird.git/commitdiff
Enable CSRF and Comment Moderation
authorBrett Parker <iDunno@sommitrealweird.co.uk>
Tue, 12 Jun 2012 13:03:38 +0000 (14:03 +0100)
committerBrett Parker <iDunno@sommitrealweird.co.uk>
Tue, 12 Jun 2012 13:03:38 +0000 (14:03 +0100)
sommitrealweird/blog/models.py
sommitrealweird/settings.py
templates/comments/comment_notification_email.txt [new file with mode: 0644]

index 16347546e110e58a1f93fec0b4a5db79b9da82be..c98407ded0d508709e9b7c58b1716ea072e4e706 100644 (file)
@@ -1,3 +1,4 @@
+from django.contrib.comments.moderation import CommentModerator, moderator
 from django.db import models
 from django.conf import settings
 from django.contrib import admin
@@ -28,6 +29,14 @@ class BlogEntry(models.Model):
     class Meta:
         ordering = ['-publish_date']
 
+class BlogEntryCommentModerator(CommentModerator):
+    email_notification = True
+
+    def moderate(self, comment, content_object, request):
+        return True
+
+moderator.register(BlogEntry, BlogEntryCommentModerator)
+
 class BlogSection(models.Model):
     title = models.CharField(max_length=150)
     slug = models.SlugField()
index 46627e7d6f741c9184319c3eb0dda29efe79fae9..41f9656cc9c13e3b8376b7db0efbfb0b75a73de6 100644 (file)
@@ -51,6 +51,7 @@ MIDDLEWARE_CLASSES = (
     'django.middleware.common.CommonMiddleware',
     'django.contrib.sessions.middleware.SessionMiddleware',
     'django.contrib.auth.middleware.AuthenticationMiddleware',
+    'django.middleware.csrf.CsrfViewMiddleware',
     'django.middleware.doc.XViewMiddleware',
 )
 
diff --git a/templates/comments/comment_notification_email.txt b/templates/comments/comment_notification_email.txt
new file mode 100644 (file)
index 0000000..63f1493
--- /dev/null
@@ -0,0 +1,3 @@
+A comment has been posted on {{ content_object }}.
+The comment reads as follows:
+{{ comment }}