From 64484656099dfff360742f3a2c1e4d07bc1f6bd8 Mon Sep 17 00:00:00 2001 From: Brett Parker Date: Tue, 12 Jun 2012 14:03:38 +0100 Subject: [PATCH] Enable CSRF and Comment Moderation --- sommitrealweird/blog/models.py | 9 +++++++++ sommitrealweird/settings.py | 1 + templates/comments/comment_notification_email.txt | 3 +++ 3 files changed, 13 insertions(+) create mode 100644 templates/comments/comment_notification_email.txt 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 }} -- 2.39.5