mirror of
https://github.com/TrentSPalmer/trentpalmerdotorg.git
synced 2024-11-14 06:11:31 -08:00
49 lines
1.6 KiB
Python
49 lines
1.6 KiB
Python
from django.shortcuts import render, reverse
|
|
from django.contrib.sites.shortcuts import get_current_site
|
|
from .models import Feed, Episode
|
|
from tp.settings import IMAGES_URL, MP3_URL
|
|
|
|
|
|
def home(request):
|
|
episodes = Episode.objects.all().order_by('-pub_date')
|
|
return render(
|
|
request,
|
|
'audio/index.html',
|
|
{
|
|
'episodes': episodes, 'IMAGES_URL': IMAGES_URL,
|
|
'MP3_URL': MP3_URL, 'add_feed_link': True})
|
|
|
|
|
|
def feed(request, pk, slug):
|
|
feed = Feed.objects.get(id=pk)
|
|
episodes = feed.episode_set.all().order_by('-pub_date')
|
|
return render(
|
|
request, 'audio/index.html',
|
|
{
|
|
'episodes': episodes, 'IMAGES_URL': IMAGES_URL, 'view': 'feed',
|
|
'MP3_URL': MP3_URL, 'title': feed.title, 'heading': feed.title,
|
|
'feed_pk': pk, 'feed_slug': slug,
|
|
})
|
|
|
|
|
|
def episode(request, pk, slug):
|
|
episode = Episode.objects.get(id=pk)
|
|
ogurl = reverse('audio:episode', kwargs={'pk': pk, 'slug': slug})
|
|
og_url = f'{get_current_site(request)}{ogurl}'
|
|
return render(
|
|
request, 'audio/index.html',
|
|
{
|
|
'episodes': (episode, ), 'IMAGES_URL': IMAGES_URL, 'is_episode': True,
|
|
'MP3_URL': MP3_URL, 'title': episode.title, 'heading': episode.title,
|
|
'ogtitle': episode.title, 'ogurl': og_url, 'ogmp3': episode.mp3,
|
|
'feed': episode.feed, 'twitter_image': episode.image,
|
|
})
|
|
|
|
|
|
def feeds(request):
|
|
feeds = Feed.objects.all().order_by('-created_on')
|
|
return render(
|
|
request,
|
|
'audio/feeds.html',
|
|
{'feeds': feeds, 'IMAGES_URL': IMAGES_URL})
|