summaryrefslogtreecommitdiff
path: root/app/podcasts/views.py
blob: 9f955b56a9f74d6e4fe965a68896f1d0cdc5eb76 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
from django.views.generic import ListView
from django.views.generic.detail import DetailView
from django.views.generic.dates import DateDetailView
from django.urls import reverse
from django.contrib.syndication.views import Feed
from django.apps import apps
from django.shortcuts import get_object_or_404
from django.conf import settings
from django.db.models import Q

from utils.views import PaginatedListView, LuxDetailView

from .models import Episode, Podcast


class PodcastListView(PaginatedListView):
    """
    Return a list of Episodes in reverse chronological order
    """
    model = Podcast
    template_name = "podcasts/list.html"
    queryset = Episode.objects.filter(podcast=1).filter(status__exact=1).order_by('-pub_date')
    
    def get_context_data(self, **kwargs):
        context = super(PodcastListView, self).get_context_data(**kwargs)
        context['breadcrumbs'] = ['podcast',]
        context['podcast'] = Podcast.objects.get(slug=self.kwargs['slug'])
        return context


class PodcastDetailView(LuxDetailView):
    """
    Return a single episodes
    """
    model = Podcast
    template_name = "podcasts/detail.html"
    
    def get_context_data(self, **kwargs):
        context = super(PodcastListView, self).get_context_data(**kwargs)
        context['breadcrumbs'] = ['podcast',]
        context['podcast'] = Podcast.objects.get(slug=self.kwargs['slug'])
        return context


class EpisodeListView(PaginatedListView):
    """
    Return a list of Episodes in reverse chronological order
    """
    model = Episode 
    template_name = "podcasts/list-episode.html"
    
    def get_context_data(self, **kwargs):
        context = super(EpisodeListView, self).get_context_data(**kwargs)
        context['breadcrumbs'] = ['podcast',]
        context['podcast'] = Podcast.objects.get(slug=self.kwargs['slug'])
        return context