summaryrefslogtreecommitdiff
path: root/program/views.py
blob: a3d180736a86025d36109b02c1e7b9ebbfd72ed8 (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
from django.views.generic import ListView

from models import BroadcastFormat, MusicFocus, Note, Show, ShowInformation, ShowTopic

from datetime import datetime, timedelta

class ShowListView(ListView):
    context_object_name = 'show_list'
    model = Show

    def get_context_data(self, **kwargs):
        context = super(ShowListView, self).get_context_data(**kwargs)

        context['broadcastformat_list'] = BroadcastFormat.objects.all()
        context['musicfocus_list'] = MusicFocus.objects.all()
        context['showinformation_list'] = ShowInformation.objects.all()
        context['showtopic_list'] = ShowTopic.objects.all()

        return context

class RecommendationsView(ListView):
    now = datetime.now()
    in_one_week = now + timedelta(weeks=1)
    context_object_name = 'recommendation_list'
    template_name = 'program/recommendations.html'
    queryset = Note.objects.filter(status=1, timeslot__start__range=(now, in_one_week))[:10]

class RecommendationsBoxView(RecommendationsView):
    now = datetime.now()
    in_one_week = now + timedelta(weeks=1)
    queryset = Note.objects.filter(status=1, timeslot__start__range=(now, in_one_week))[:3]