]> git.sommitrealweird.co.uk Git - sommitrealweird.git/blobdiff - sommitrealweird/blog/models.py
Clean up photos so that it does 404s
[sommitrealweird.git] / sommitrealweird / blog / models.py
index 757367423f49ed207a033785c9367152a81e6b72..fa2e954f49e8319a031b93a3ea5174c758eab730 100644 (file)
@@ -1,5 +1,7 @@
+from django.contrib.comments.moderation import CommentModerator, moderator
 from django.db import models
 from django.conf import settings
+from django.contrib import admin
 
 FORMAT_CHOICES = (
     ('rst', 'reStructuredText'),
@@ -7,11 +9,11 @@ FORMAT_CHOICES = (
 )
 
 class BlogEntry(models.Model):
-    title = models.CharField(maxlength=150)
-    islive = models.BooleanField()
+    title = models.CharField(max_length=150)
+    islive = models.BooleanField(default=False)
     sections = models.ManyToManyField('BlogSection')
-    format = models.CharField(maxlength=10, choices=FORMAT_CHOICES)
-    slug = models.SlugField(prepopulate_from=("title",))
+    format = models.CharField(max_length=10, choices=FORMAT_CHOICES)
+    slug = models.SlugField()
     publish_date = models.DateTimeField()
     content = models.TextField()
 
@@ -27,12 +29,20 @@ class BlogEntry(models.Model):
     class Meta:
         ordering = ['-publish_date']
 
-    class Admin:
-        pass
+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(maxlength=150)
-    slug = models.SlugField(prepopulate_from=("title",))
+    title = models.CharField(max_length=150)
+    slug = models.SlugField()
 
     def __str__(self):
         return self.__unicode__()
@@ -42,6 +52,3 @@ class BlogSection(models.Model):
 
     def get_absolute_url(self):
         return u'%ssection/%s/' %(settings.BLOG_ROOT, self.slug)
-
-    class Admin:
-        pass