X-Git-Url: https://git.sommitrealweird.co.uk/sommitrealweird.git/blobdiff_plain/2d5a803e2b8bd6ed72de946d4cfbb7b880493bf6..ade662a8e015bcecdc58512f915e4f56d16a56ed:/sommitrealweird/blog/models.py?ds=sidebyside diff --git a/sommitrealweird/blog/models.py b/sommitrealweird/blog/models.py index 1634754..f76de30 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,17 @@ class BlogEntry(models.Model): class Meta: ordering = ['-publish_date'] +class BlogEntryCommentModerator(CommentModerator): + email_notification = True + + def moderate(self, comment, content_object, request): + if request.user.is_authenticated(): + return False + else: + return True + +moderator.register(BlogEntry, BlogEntryCommentModerator) + class BlogSection(models.Model): title = models.CharField(max_length=150) slug = models.SlugField()