diff options
author | Ernesto Rico-Schmidt <e.rico.schmidt@gmail.com> | 2011-03-25 20:11:51 (GMT) |
---|---|---|
committer | Ernesto Rico-Schmidt <e.rico.schmidt@gmail.com> | 2011-03-25 20:11:51 (GMT) |
commit | 9c6be4e8eed0162555e67228cf8a923f3e24135e (patch) | |
tree | 1fbf14ef94b4d1d137715aa73a28802b93142768 /program | |
parent | 957661c9b9fbefd1a2e7302911fe2e3e793f34ef (diff) |
added filtering and day context variable to day/today schedule, renamed template for current view.
Diffstat (limited to 'program')
-rw-r--r-- | program/views.py | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/program/views.py b/program/views.py index 10d193b..23c1483 100644 --- a/program/views.py +++ b/program/views.py @@ -1,6 +1,5 @@ from django.views.generic.list import ListView from django.views.generic.base import TemplateView -from django.views.generic.dates import DayArchiveView, TodayArchiveView, WeekArchiveView from django.shortcuts import get_object_or_404 from models import BroadcastFormat, MusicFocus, Note, Show, ShowInformation, ShowTopic, TimeSlot @@ -60,9 +59,16 @@ class TodayScheduleView(TemplateView): today = datetime.combine(date.today(), time(6, 0)) tomorrow = datetime.combine(date.today()+timedelta(days=1), time(6, 0)) + context['day'] = today context['broadcastformats'] = BroadcastFormat.objects.all() context['recommendations'] = Note.objects.filter(status=1, timeslot__start__range=(now, tomorrow)) - context['timeslots'] = TimeSlot.objects.filter(start__range=(today, tomorrow)) + + if 'broadcastformat' in self.request.GET: + broadcastformat = get_object_or_404(BroadcastFormat, slug=self.request.GET['broadcastformat']) + + context['timeslots'] = TimeSlot.objects.filter(start__range=(today, tomorrow), show__broadcastformat=broadcastformat) + else: + context['timeslots'] = TimeSlot.objects.filter(start__range=(today, tomorrow)) return context @@ -80,13 +86,21 @@ class DayScheduleView(TemplateView): this_day = datetime.strptime('%s__%s__%s__06__00' % (year, month, day), '%Y__%m__%d__%H__%M') that_day = this_day+timedelta(days=1) + context['day'] = this_day context['broadcastformats'] = BroadcastFormat.objects.all() context['recommendations'] = Note.objects.filter(status=1, timeslot__start__range=(this_day, that_day)) - context['timeslots'] = TimeSlot.objects.filter(start__range=(this_day, that_day)) + + if 'broadcastformat' in self.request.GET: + broadcastformat = get_object_or_404(BroadcastFormat, slug=self.request.GET['broadcastformat']) + + context['timeslots'] = TimeSlot.objects.filter(start__range=(this_day, that_day), show__broadcastformat=broadcastformat) + else: + context['timeslots'] = TimeSlot.objects.filter(start__range=(this_day, that_day)) + return context class CurrentShowView(TemplateView): - template_name = 'program/current.html' + template_name = 'program/current_box.html' def get_context_data(self, **kwargs): context = super(CurrentShowView, self).get_context_data(**kwargs) |