ckridgway@16: """ ckridgway@16: Models for the reviews application. ckridgway@16: ckridgway@16: """ ckridgway@16: from django.db import models ckridgway@45: from datetime import timedelta, datetime ckridgway@45: from django.core.urlresolvers import reverse ckridgway@16: ckridgway@16: class Review(models.Model): ckridgway@16: """ ckridgway@16: This model represents all the info we store about each review. ckridgway@16: """ ckridgway@34: date = models.DateTimeField(auto_now_add=True) ckridgway@28: title = models.CharField(max_length=200) ckridgway@16: reviewer = models.CharField(max_length=200) ckridgway@16: review_site = models.CharField(max_length=200, blank=True) ckridgway@16: review_url = models.URLField(verify_exists=False, max_length=256, blank=True) ckridgway@16: review = models.TextField() ckridgway@16: ckridgway@16: class Meta: ckridgway@16: verbose_name_plural = "Reviews" ckridgway@28: ordering = ['-date'] ckridgway@16: ckridgway@16: def __unicode__(self): ckridgway@16: return self.reviewer ckridgway@45: ckridgway@45: def is_new(self): ckridgway@45: if datetime.now() - self.date <= timedelta(days=30): ckridgway@45: return True ckridgway@45: return False ckridgway@45: ckridgway@45: def get_absolute_url(self): ckridgway@45: return reverse('reviews') + '#review%d' % self.id