comparison podcast/views.py @ 1032:e932f2ecd4a7

Django 1.8 warnings / tech debt cleanup.
author Brian Neal <bgneal@gmail.com>
date Sat, 26 Dec 2015 15:10:55 -0600
parents 89b240fe9297
children aa43db10c565
comparison
equal deleted inserted replaced
1031:e1c03da72818 1032:e932f2ecd4a7
4 """ 4 """
5 import json 5 import json
6 import os.path 6 import os.path
7 from urlparse import urlparse 7 from urlparse import urlparse
8 8
9 from django.shortcuts import render_to_response 9 from django.shortcuts import render
10 from django.template import RequestContext
11 from django.shortcuts import get_object_or_404 10 from django.shortcuts import get_object_or_404
12 11
13 from podcast.models import Channel 12 from podcast.models import Channel
14 from podcast.models import Item 13 from podcast.models import Item
15 14
59 try: 58 try:
60 channel = Channel.objects.get(pk=1) 59 channel = Channel.objects.get(pk=1)
61 except Channel.DoesNotExist: 60 except Channel.DoesNotExist:
62 channel = None 61 channel = None
63 62
64 return render_to_response('podcast/index.html', { 63 return render(request, 'podcast/index.html', {
65 'channel': channel, 64 'channel': channel,
66 }, 65 })
67 context_instance = RequestContext(request))
68 66
69 67
70 def detail(request, id): 68 def detail(request, id):
71 podcast = get_object_or_404(Item.objects.select_related(), pk = id) 69 podcast = get_object_or_404(Item.objects.select_related(), pk = id)
72 70
76 alt_ext = get_ext_from_url(podcast.alt_enclosure_url) 74 alt_ext = get_ext_from_url(podcast.alt_enclosure_url)
77 75
78 jplayer_media, jplayer_supplied = jplayer_params(ext, podcast.enclosure_url, 76 jplayer_media, jplayer_supplied = jplayer_params(ext, podcast.enclosure_url,
79 alt_ext, podcast.alt_enclosure_url) 77 alt_ext, podcast.alt_enclosure_url)
80 78
81 return render_to_response('podcast/detail.html', { 79 return render(request, 'podcast/detail.html', {
82 'channel': podcast.channel, 80 'channel': podcast.channel,
83 'podcast': podcast, 81 'podcast': podcast,
84 'ext': ext, 82 'ext': ext,
85 'alt_ext': alt_ext, 83 'alt_ext': alt_ext,
86 'jplayer_media': jplayer_media, 84 'jplayer_media': jplayer_media,
87 'jplayer_supplied': jplayer_supplied, 85 'jplayer_supplied': jplayer_supplied,
88 }, 86 })
89 context_instance = RequestContext(request))
90 87
91 88
92 def feed(request): 89 def feed(request):
93 try: 90 try:
94 channel = Channel.objects.get(pk=1) 91 channel = Channel.objects.get(pk=1)
96 channel = None 93 channel = None
97 94
98 if channel: 95 if channel:
99 channel.items = Item.objects.filter(channel=channel) 96 channel.items = Item.objects.filter(channel=channel)
100 97
101 return render_to_response('podcast/feed.xml', { 98 return render(request, 'podcast/feed.xml', {
102 'channel': channel, 99 'channel': channel,
103 }, 100 })
104 context_instance = RequestContext(request))