# HG changeset patch # User Brian Neal # Date 1260134911 0 # Node ID 1ed461fd20306bb3b0b5b39857279dc6704d065a # Parent f6904149a2330d5bad676229769e52549ea40840 Podcast enhancements for #39. Provide channel level keyword support. Provide an alternate download URL so we can support both m4a and mp3 formats. diff -r f6904149a233 -r 1ed461fd2030 gpp/podcast/models.py --- a/gpp/podcast/models.py Sun Dec 06 21:25:00 2009 +0000 +++ b/gpp/podcast/models.py Sun Dec 06 21:28:31 2009 +0000 @@ -24,6 +24,7 @@ image = models.ImageField(upload_to='podcast') category = models.CharField(max_length=64) explicit = models.CharField(max_length=8, choices=EXPLICIT_CHOICES) + keywords = models.CharField(max_length=255) def __unicode__(self): return self.title @@ -37,6 +38,7 @@ subtitle = models.CharField(max_length=255) summary = models.TextField() enclosure_url = models.URLField(verify_exists=False) + alt_enclosure_url = models.URLField(verify_exists=False, blank=True) enclosure_length = models.IntegerField() enclosure_type = models.CharField(max_length=32) guid = models.CharField(max_length=255) diff -r f6904149a233 -r 1ed461fd2030 gpp/podcast/views.py --- a/gpp/podcast/views.py Sun Dec 06 21:25:00 2009 +0000 +++ b/gpp/podcast/views.py Sun Dec 06 21:28:31 2009 +0000 @@ -1,4 +1,6 @@ """Views for the podcast application""" +import os.path +from urlparse import urlparse from django.shortcuts import render_to_response from django.template import RequestContext @@ -8,6 +10,14 @@ from podcast.models import Item +def get_ext_from_url(url): + """ + This function returns the extension part of the path from the given + url. + """ + return os.path.splitext(urlparse(url).path)[1] + + def index(request): try: channel = Channel.objects.get(pk=1) @@ -21,10 +31,18 @@ def detail(request, id): - podcast = get_object_or_404(Item, pk = id) + podcast = get_object_or_404(Item.objects.select_related(), pk = id) + + ext = get_ext_from_url(podcast.enclosure_url) + alt_ext = None + if podcast.alt_enclosure_url: + alt_ext = get_ext_from_url(podcast.alt_enclosure_url) + return render_to_response('podcast/detail.html', { 'channel': podcast.channel, 'podcast': podcast, + 'ext': ext, + 'alt_ext': alt_ext, }, context_instance = RequestContext(request)) diff -r f6904149a233 -r 1ed461fd2030 gpp/templates/podcast/detail.html --- a/gpp/templates/podcast/detail.html Sun Dec 06 21:25:00 2009 +0000 +++ b/gpp/templates/podcast/detail.html Sun Dec 06 21:28:31 2009 +0000 @@ -7,6 +7,15 @@

{{ podcast.pubdate|date:"F d, Y" }} • {{ podcast.title }}

{{ podcast.subtitle }}

{{ podcast.summary|linebreaks }} -

Download Now • -{{ podcast.enclosure_length|filesizeformat }} • {{ podcast.duration }}

+ {% endblock %} diff -r f6904149a233 -r 1ed461fd2030 gpp/templates/podcast/feed.xml --- a/gpp/templates/podcast/feed.xml Sun Dec 06 21:25:00 2009 +0000 +++ b/gpp/templates/podcast/feed.xml Sun Dec 06 21:28:31 2009 +0000 @@ -13,6 +13,7 @@ {{ channel.author }} {{ channel.description }} {{ channel.description }} +{{ channel.keywords }} {{ channel.owner_name }} {{ channel.owner_email }}