From: Brett Parker Date: Tue, 12 Jun 2012 13:03:38 +0000 (+0100) Subject: Enable CSRF and Comment Moderation X-Git-Url: https://git.sommitrealweird.co.uk/sommitrealweird.git/commitdiff_plain/64484656099dfff360742f3a2c1e4d07bc1f6bd8?hp=992930de1234506ede31838a265a776a76e382de Enable CSRF and Comment Moderation --- diff --git a/sommitrealweird/blog/models.py b/sommitrealweird/blog/models.py index 1634754..c98407d 100644 --- a/sommitrealweird/blog/models.py +++ b/sommitrealweird/blog/models.py @@ -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() diff --git a/sommitrealweird/settings.py b/sommitrealweird/settings.py index 46627e7..41f9656 100644 --- a/sommitrealweird/settings.py +++ b/sommitrealweird/settings.py @@ -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 index 0000000..63f1493 --- /dev/null +++ b/templates/comments/comment_notification_email.txt @@ -0,0 +1,3 @@ +A comment has been posted on {{ content_object }}. +The comment reads as follows: +{{ comment }}