From 9c6be4e8eed0162555e67228cf8a923f3e24135e Mon Sep 17 00:00:00 2001 From: Ernesto Rico-Schmidt Date: Fri, 25 Mar 2011 21:11:51 +0100 Subject: added filtering and day context variable to day/today schedule, renamed template for current view. 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) diff --git a/templates/program/current.html b/templates/program/current.html deleted file mode 100644 index 193762a..0000000 --- a/templates/program/current.html +++ /dev/null @@ -1,22 +0,0 @@ - - - Current program - - - -
-
- {{ current }} -
- -
- {{ next }} -
- -
- {{ after_next }} -
-
- - - \ No newline at end of file diff --git a/templates/program/current_box.html b/templates/program/current_box.html new file mode 100644 index 0000000..3977994 --- /dev/null +++ b/templates/program/current_box.html @@ -0,0 +1,39 @@ + + + Current program box + + + + +
+
Programm derzeit
+ +
+
{{ current.start|date:"H:i" }}
+
+ + {% if current.note %} +
{{ current.note.title }}
+ {% else %} +
{{ current.show.short_description }}
+ {% endif %} +
+
+ +
+
{{ next.start|date:"H:i" }}
+ +
+ +
+
{{ after_next.start|date:"H:i" }}
+ +
+
+ + + \ No newline at end of file -- cgit v0.10.2