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()
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):
38 moderator.register(BlogEntry, BlogEntryCommentModerator)
40 class BlogSection(models.Model):
41 title = models.CharField(max_length=150)
42 slug = models.SlugField()
45 return self.__unicode__()
47 def __unicode__(self):
48 return u'%s' %(self.title,)
50 def get_absolute_url(self):
51 return u'%ssection/%s/' %(settings.BLOG_ROOT, self.slug)