bgneal@45: """
bgneal@45: Models for the news application.
bgneal@45: 
bgneal@45: """
bgneal@45: from django.db import models
bgneal@45: 
bgneal@45: 
bgneal@45: class News(models.Model):
bgneal@45:     """
bgneal@45:     This model represents all the info we store about each news entry.
bgneal@45: 
bgneal@45:     """
bgneal@45:     title = models.CharField(max_length=128, blank=True)
bgneal@45:     date = models.DateTimeField(db_index=True)
bgneal@45:     content = models.TextField()
bgneal@45: 
bgneal@45:     def __unicode__(self):
bgneal@45:         date_str = self.date.strftime('%m/%d/%Y')
bgneal@45:         if self.title:
bgneal@45:             return u'%s %s' % (date_str, self.title)
bgneal@45:         return u'%s' % date_str
bgneal@45: 
bgneal@45:     @models.permalink
bgneal@45:     def get_absolute_url(self):
bgneal@45:         return ('news-item', [], {'pk': str(self.id)})
bgneal@45: 
bgneal@45:     class Meta:
bgneal@45:         verbose_name_plural = 'News'
bgneal@45:         ordering = ['-date']