Package madrona :: Package news :: Module models
[hide private]

Source Code for Module madrona.news.models

 1  from django.db import models 
 2  from django.contrib.auth.models import User 
 3  from django.template.defaultfilters import slugify 
 4  import datetime 
 5   
6 -class Tag(models.Model):
7 name = models.CharField(max_length=50) 8 slug = models.SlugField(editable=False) 9
10 - def __unicode__(self):
11 return self.name
12
13 - def save(self, *args, **kwargs):
14 if not self.id: 15 self.slug = slugify(self.name) 16 super(Tag, self).save(*args, **kwargs)
17
18 -class Entry(models.Model):
19 title = models.CharField(max_length=200) 20 slug = models.SlugField(editable=False) 21 summary = models.CharField(max_length=200,blank=True,null=True,help_text="One sentence. If not supplied, whole body text will show up in archive view.") 22 body = models.TextField(help_text="Use HTML.") 23 tags = models.ManyToManyField(Tag) 24 author = models.ForeignKey(User) 25 is_draft = models.BooleanField("Draft", default=False, help_text="Check if this is a draft.") 26 published_on = models.DateTimeField(auto_now_add=True) 27 modified_on = models.DateTimeField(auto_now=True,editable=False) 28
29 - class Meta:
30 verbose_name_plural = 'Entries' 31 ordering = ('-published_on',) 32 get_latest_by = 'published_on'
33
34 - def __unicode__(self):
35 return self.title
36
37 - def save(self, *args, **kwargs):
38 if not self.id: 39 self.slug = slugify(self.title) 40 super(Entry, self).save(*args, **kwargs)
41