X-Git-Url: https://git.sommitrealweird.co.uk/sommitrealweird.git/blobdiff_plain/2e02e107aff23d09c81ac970101ebe2f9ce5e760..bb8272178c6c35fcb92bc5a08342faf40d3fab1b:/sommitrealweird/blog/models.py diff --git a/sommitrealweird/blog/models.py b/sommitrealweird/blog/models.py new file mode 100644 index 0000000..6b0d254 --- /dev/null +++ b/sommitrealweird/blog/models.py @@ -0,0 +1,44 @@ +from django.db import models +from django.conf import settings + +FORMAT_CHOICES = ( + ('rst', 'reStructuredText'), + ('html', 'HTML'), +) + +class BlogEntry(models.Model): + title = models.CharField(maxlength=150) + islive = models.BooleanField() + sections = models.ManyToManyField('BlogSection') + format = models.CharField(maxlength=10, choices=FORMAT_CHOICES) + slug = models.SlugField(prepopulate_from=("title",)) + publish_date = models.DateTimeField() + content = models.TextField() + + def __str__(self): + return self.__unicode__() + + def __unicode__(self): + return u'%s - %s' %(self.publish_date.strftime('%Y-%m-%d %H:%M'), self.title) + + def get_absolute_url(self): + return u'%s%04d/%02d/%02d/%s/' %(settings.BLOG_ROOT, self.publish_date.year, self.publish_date.month, self.publish_date.day, self.slug) + + class Admin: + pass + +class BlogSection(models.Model): + title = models.CharField(maxlength=150) + slug = models.SlugField(prepopulate_from=("title",)) + + def __str__(self): + return self.__unicode__() + + def __unicode__(self): + return u'%s' %(self.title,) + + def get_absolute_url(self): + return u'%ssection/%s/' %(settings.BLOG_ROOT, self.slug) + + class Admin: + pass