gremmie@1: """Models for the podcast application.""" gremmie@1: gremmie@1: from django.db import models gremmie@1: gremmie@1: EXPLICIT_CHOICES = ( bgneal@224: ('yes', 'Yes'), bgneal@224: ('no', 'No'), bgneal@224: ('clean', 'Clean'), bgneal@224: ) gremmie@1: gremmie@1: gremmie@1: class Channel(models.Model): bgneal@224: """Model to represent the Channel properties""" gremmie@1: bgneal@224: title = models.CharField(max_length=255) bgneal@224: link = models.URLField(verify_exists=False) bgneal@224: language = models.CharField(max_length=16) bgneal@224: copyright = models.CharField(max_length=255) bgneal@224: subtitle = models.CharField(max_length=255) bgneal@224: author = models.CharField(max_length=64) bgneal@224: description = models.CharField(max_length=255) bgneal@224: owner_name = models.CharField(max_length=64) bgneal@224: owner_email = models.EmailField() bgneal@224: image = models.ImageField(upload_to='podcast') bgneal@224: category = models.CharField(max_length=64) bgneal@224: explicit = models.CharField(max_length=8, choices=EXPLICIT_CHOICES) bgneal@224: keywords = models.CharField(max_length=255) gremmie@1: bgneal@224: def __unicode__(self): bgneal@224: return self.title gremmie@1: gremmie@1: gremmie@1: class Item(models.Model): bgneal@224: """Model to represent a channel item""" bgneal@224: channel = models.ForeignKey(Channel) bgneal@224: title = models.CharField(max_length=255) bgneal@224: author = models.CharField(max_length=255) bgneal@224: subtitle = models.CharField(max_length=255) bgneal@224: summary = models.TextField() bgneal@224: enclosure_url = models.URLField(verify_exists=False) bgneal@224: alt_enclosure_url = models.URLField(verify_exists=False, blank=True) bgneal@224: enclosure_length = models.IntegerField() bgneal@224: enclosure_type = models.CharField(max_length=32) bgneal@224: guid = models.CharField(max_length=255) bgneal@224: pubdate = models.DateTimeField() bgneal@224: duration = models.CharField(max_length=16) bgneal@224: keywords = models.CharField(max_length=255) bgneal@224: explicit = models.CharField(max_length=8, choices=EXPLICIT_CHOICES) gremmie@1: bgneal@224: @models.permalink bgneal@224: def get_absolute_url(self): bgneal@224: return ('podcast.views.detail', [str(self.id)]) gremmie@1: bgneal@224: def __unicode__(self): bgneal@224: return self.title gremmie@1: bgneal@224: class Meta: bgneal@224: ordering = ('-pubdate', ) gremmie@1: bgneal@224: def search_title(self): bgneal@224: return "%s: %s" % (self.title, self.subtitle) bgneal@224: bgneal@224: def search_summary(self): bgneal@224: return u"\n".join((self.subtitle, self.summary, self.keywords))