]> git.sommitrealweird.co.uk Git - sommitrealweird.git/blob - sommitrealweird/blog/models.py
Add caching for submenus
[sommitrealweird.git] / sommitrealweird / blog / models.py
1 from django.db import models
2 from django.conf import settings
3
4 FORMAT_CHOICES = (
5     ('rst', 'reStructuredText'),
6     ('html', 'HTML'),
7 )
8
9 class BlogEntry(models.Model):
10     title = models.CharField(maxlength=150)
11     islive = models.BooleanField()
12     sections = models.ManyToManyField('BlogSection')
13     format = models.CharField(maxlength=10, choices=FORMAT_CHOICES)
14     slug = models.SlugField(prepopulate_from=("title",))
15     publish_date = models.DateTimeField()
16     content = models.TextField()
17
18     def __str__(self):
19         return self.__unicode__()
20
21     def __unicode__(self):
22         return u'%s - %s' %(self.publish_date.strftime('%Y-%m-%d %H:%M'), self.title)
23
24     def get_absolute_url(self):
25         return u'%s%04d/%02d/%02d/%s/' %(settings.BLOG_ROOT, self.publish_date.year, self.publish_date.month, self.publish_date.day, self.slug)
26
27     class Admin:
28         pass
29
30 class BlogSection(models.Model):
31     title = models.CharField(maxlength=150)
32     slug = models.SlugField(prepopulate_from=("title",))
33
34     def __str__(self):
35         return self.__unicode__()
36
37     def __unicode__(self):
38         return u'%s' %(self.title,)
39
40     def get_absolute_url(self):
41         return u'%ssection/%s/' %(settings.BLOG_ROOT, self.slug)
42
43     class Admin:
44         pass