Mercurial > public > bravenewsurf
annotate bns_website/news/models.py @ 67:a878a98292a8
Merging new front page design from experimental UI branch.
author | Chris Ridgway <ckridgway@gmail.com> |
---|---|
date | Sun, 20 Nov 2011 22:59:06 -0600 |
parents | 9ce9f77d6cde |
children |
rev | line source |
---|---|
bob@14 | 1 from django.db import models |
bob@23 | 2 from datetime import timedelta, datetime |
bob@41 | 3 from django.core.urlresolvers import reverse |
bob@14 | 4 |
bob@14 | 5 # Create your models here. |
bob@14 | 6 class News(models.Model): |
bob@14 | 7 """ |
bob@14 | 8 This model represents all the info we store about each news entry. |
bob@14 | 9 |
bob@14 | 10 """ |
bob@14 | 11 title = models.CharField(max_length=128) |
bob@14 | 12 date = models.DateTimeField() |
bob@14 | 13 content = models.TextField() |
bob@14 | 14 |
bob@41 | 15 def __unicode__(self): |
bob@41 | 16 return self.title |
bob@14 | 17 |
bob@23 | 18 def is_new(self): |
bob@37 | 19 if datetime.now() - self.date <= timedelta(days=30): |
bob@23 | 20 return True |
bob@23 | 21 return False |
bob@23 | 22 |
bob@41 | 23 def get_absolute_url(self): |
bob@41 | 24 return reverse('news') + '#news%d' % self.id |
bob@14 | 25 |
bob@14 | 26 class Meta: |
bob@14 | 27 verbose_name_plural="News" |
bob@21 | 28 ordering = ['-date'] |