Mercurial > public > bravenewsurf
annotate bns_website/news/models.py @ 28:20dc7be59c85
Addresses three items from #2, comment #2.
1. Made review title a mandatory field
3. Changed reviews display to use Bootstrap <blockquote> instead of <cite>
4. Ordering of reviews is now reverse chronological
see ticket #2
author | Chris Ridgway <ckridgway@gmail.com> |
---|---|
date | Thu, 03 Nov 2011 23:00:34 -0500 |
parents | 1357c69e887d |
children | 353ca3874f43 |
rev | line source |
---|---|
bob@14 | 1 from django.db import models |
bob@23 | 2 from datetime import timedelta, datetime |
bob@14 | 3 |
bob@14 | 4 # Create your models here. |
bob@14 | 5 class News(models.Model): |
bob@14 | 6 """ |
bob@14 | 7 This model represents all the info we store about each news entry. |
bob@14 | 8 |
bob@14 | 9 """ |
bob@14 | 10 title = models.CharField(max_length=128) |
bob@14 | 11 date = models.DateTimeField() |
bob@14 | 12 content = models.TextField() |
bob@14 | 13 |
bob@14 | 14 # User field? |
bob@14 | 15 |
bob@14 | 16 |
bob@23 | 17 def is_new(self): |
bob@23 | 18 if datetime.now() - self.date <= timedelta(days=3): |
bob@23 | 19 return True |
bob@23 | 20 |
bob@23 | 21 return False |
bob@23 | 22 |
bob@14 | 23 |
bob@14 | 24 class Meta: |
bob@14 | 25 verbose_name_plural="News" |
bob@21 | 26 ordering = ['-date'] |
bob@14 | 27 |
bob@14 | 28 def __unicode__(self): |
bob@14 | 29 return self.title |