Mercurial > public > bravenewsurf
annotate bns_website/reviews/models.py @ 98:4de34a1446a0
Fix video page. Was only displaying 2 videos in playlist.
YouTube must have changed something? In any event, it is easier to use
now. Can just use an <iframe> and give it a list of videos now.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Fri, 13 Jul 2012 21:36:53 -0500 |
parents | 2598bc18b6fb |
children |
rev | line source |
---|---|
ckridgway@16 | 1 """ |
ckridgway@16 | 2 Models for the reviews application. |
ckridgway@16 | 3 |
ckridgway@16 | 4 """ |
ckridgway@16 | 5 from django.db import models |
ckridgway@45 | 6 from datetime import timedelta, datetime |
ckridgway@45 | 7 from django.core.urlresolvers import reverse |
ckridgway@16 | 8 |
ckridgway@16 | 9 class Review(models.Model): |
ckridgway@16 | 10 """ |
ckridgway@16 | 11 This model represents all the info we store about each review. |
ckridgway@16 | 12 """ |
ckridgway@34 | 13 date = models.DateTimeField(auto_now_add=True) |
ckridgway@28 | 14 title = models.CharField(max_length=200) |
ckridgway@16 | 15 reviewer = models.CharField(max_length=200) |
ckridgway@16 | 16 review_site = models.CharField(max_length=200, blank=True) |
ckridgway@16 | 17 review_url = models.URLField(verify_exists=False, max_length=256, blank=True) |
ckridgway@16 | 18 review = models.TextField() |
ckridgway@16 | 19 |
ckridgway@16 | 20 class Meta: |
ckridgway@16 | 21 verbose_name_plural = "Reviews" |
ckridgway@28 | 22 ordering = ['-date'] |
ckridgway@16 | 23 |
ckridgway@16 | 24 def __unicode__(self): |
ckridgway@16 | 25 return self.reviewer |
ckridgway@45 | 26 |
ckridgway@45 | 27 def is_new(self): |
ckridgway@45 | 28 if datetime.now() - self.date <= timedelta(days=30): |
ckridgway@45 | 29 return True |
ckridgway@45 | 30 return False |
ckridgway@45 | 31 |
ckridgway@45 | 32 def get_absolute_url(self): |
ckridgway@45 | 33 return reverse('reviews') + '#review%d' % self.id |