From a48df664dd9da38b02b3dc0c82a7eb4969db5b96 Mon Sep 17 00:00:00 2001 From: Ernesto Rico-Schmidt Date: Tue, 22 Mar 2011 15:37:10 +0100 Subject: added week schedule view. diff --git a/TODO b/TODO index fbc3e80..7ffd2ac 100644 --- a/TODO +++ b/TODO @@ -1,4 +1,3 @@ -* week schedule view * integrate calendar into day schedule view * integrate tinyMCE into admin site * integrate open ID diff --git a/program/urls.py b/program/urls.py index 318ae99..6e7da79 100644 --- a/program/urls.py +++ b/program/urls.py @@ -3,11 +3,12 @@ from django.views.generic.detail import DetailView from django.views.generic.list import ListView from models import Host, Show, TimeSlot -from views import CurrentShowView, DayScheduleView, RecommendationsView, ShowListView, TodayScheduleView +from views import CurrentShowView, DayScheduleView, RecommendationsView, ShowListView, TodayScheduleView, WeekScheduleView urlpatterns = patterns('', ('^$', TodayScheduleView.as_view()), ('^(?P\d{4})/(?P\d{1,2})/(?P\d{1,2})/$', DayScheduleView.as_view()), + ('^(?P\d{4})/(?P\d{1,2})/$', WeekScheduleView.as_view()), ('^current/$', CurrentShowView.as_view()), ('^hosts/$', ListView.as_view(model=Host, context_object_name='hosts')), url('^host/(?P\d+)/$', DetailView.as_view(model=Host), name='host-detail'), diff --git a/program/views.py b/program/views.py index a9eabbc..1fa84af 100644 --- a/program/views.py +++ b/program/views.py @@ -1,6 +1,6 @@ from django.views.generic.list import ListView from django.views.generic.base import TemplateView -from django.views.generic.dates import DayArchiveView, TodayArchiveView +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 @@ -98,4 +98,42 @@ class CurrentShowView(TemplateView): context['next'] = TimeSlot.objects.get_or_create_current().get_next_by_start() context['after_next'] = TimeSlot.objects.get_or_create_current().get_next_by_start().get_next_by_start() - return context \ No newline at end of file + return context + +class WeekScheduleView(TemplateView): + template_name = 'program/week_schedule.html' + + def get_context_data(self, **kwargs): + context = super(WeekScheduleView, self).get_context_data(**kwargs) + + year = context['params']['year'] + week = context['params']['week'] + + # start the day at 6 + monday = datetime.strptime('%s__%s__1__06__00' % (year, week), '%Y__%W__%w__%H__%M') + + tuesday = monday+timedelta(days=1) + wednesday = monday+timedelta(days=2) + thursday = monday+timedelta(days=3) + friday = monday+timedelta(days=4) + saturday = monday+timedelta(days=5) + sunday = monday+timedelta(days=6) + next_monday = monday+timedelta(days=7) + + context['monday'] = monday + context['tuesday'] = tuesday + context['wednesday'] = wednesday + context['thursday'] = thursday + context['friday'] = friday + context['saturday'] = saturday + context['sunday'] = sunday + + context['monday_timeslots'] = TimeSlot.objects.filter(start__range=(monday, tuesday)) + context['tuesday_timeslots'] = TimeSlot.objects.filter(start__range=(tuesday, wednesday)) + context['wednesday_timeslots'] = TimeSlot.objects.filter(start__range=(wednesday, thursday)) + context['thursday_timeslots'] = TimeSlot.objects.filter(start__range=(thursday, friday)) + context['friday_timeslots'] = TimeSlot.objects.filter(start__range=(friday, saturday)) + context['saturday_timeslots'] = TimeSlot.objects.filter(start__range=(saturday, sunday)) + context['sunday_timeslots'] = TimeSlot.objects.filter(start__range=(sunday, next_monday)) + + return context diff --git a/templates/program/week_schedule.html b/templates/program/week_schedule.html new file mode 100644 index 0000000..2969d28 --- /dev/null +++ b/templates/program/week_schedule.html @@ -0,0 +1,87 @@ + + + Week schedule + + + + +
+
+
06:00
+
07:00
+
08:00
+
09:00
+
10:00
+
11:00
+
12:00
+
13:00
+
14:00
+
15:00
+
16:00
+
17:00
+
18:00
+
19:00
+
20:00
+
21:00
+
22:00
+
23:00
+
00:00
+
01:00
+
02:00
+
03:00
+
04:00
+
05:00
+
+ +
+
{{ monday|date:"l d.m.Y" }}
+ {% for timeslot in monday_timeslots %} + + {% endfor %} +
+ +
+
{{ tuesday|date:"l d.m.Y" }}
+ {% for timeslot in tuesday_timeslots %} + + {% endfor %} +
+ +
+
{{ wednesday|date:"l d.m.Y" }}
+ {% for timeslot in wednesday_timeslots %} + + {% endfor %} +
+ +
+
{{ thursday|date:"l d.m.Y" }}
+ {% for timeslot in thursday_timeslots %} + + {% endfor %} +
+ +
+
{{ friday|date:"l d.m.Y" }}
+ {% for timeslot in friday_timeslots %} + + {% endfor %} +
+ +
+
{{ saturday|date:"l d.m.Y" }}
+ {% for timeslot in saturday_timeslots %} + + {% endfor %} +
+ +
+
{{ sunday|date:"l d.m.Y" }}
+ {% for timeslot in sunday_timeslots %} + + {% endfor %} +
+
+ + + -- cgit v0.10.2