1 from django.contrib.comments.moderation import CommentModerator, moderator
2 from django.db import models
3 from django.conf import settings
4 from django.contrib import admin
7 ('rst', 'reStructuredText'),
11 class BlogEntry(models.Model):
12 title = models.CharField(max_length=150)
13 islive = models.BooleanField(default=False)
14 sections = models.ManyToManyField('BlogSection')
15 format = models.CharField(max_length=10, choices=FORMAT_CHOICES)
16 slug = models.SlugField()
17 publish_date = models.DateTimeField()
18 content = models.TextField()
21 return self.__unicode__()
23 def __unicode__(self):
24 return u'%s - %s' %(self.publish_date.strftime('%Y-%m-%d %H:%M'), self.title)
26 def get_absolute_url(self):
27 return u'%s%04d/%02d/%02d/%s/' %(settings.BLOG_ROOT, self.publish_date.year, self.publish_date.month, self.publish_date.day, self.slug)
30 ordering = ['-publish_date']
32 class BlogEntryCommentModerator(CommentModerator):
33 email_notification = True
35 def moderate(self, comment, content_object, request):
36 if request.user.is_authenticated():
41 moderator.register(BlogEntry, BlogEntryCommentModerator)
43 class BlogSection(models.Model):
44 title = models.CharField(max_length=150)
45 slug = models.SlugField()
48 return self.__unicode__()
50 def __unicode__(self):
51 return u'%s' %(self.title,)
53 def get_absolute_url(self):
54 return u'%ssection/%s/' %(settings.BLOG_ROOT, self.slug)