summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErnesto Rico-Schmidt <e.rico.schmidt@gmail.com>2011-03-22 14:37:10 (GMT)
committerErnesto Rico-Schmidt <e.rico.schmidt@gmail.com>2011-03-22 14:37:10 (GMT)
commita48df664dd9da38b02b3dc0c82a7eb4969db5b96 (patch)
treeea9a5518bf673886873551e0c610feba71f40858
parentbc4e14f6bd7b8df7988f547a02aa52f8065c6e43 (diff)
added week schedule view.
-rw-r--r--TODO1
-rw-r--r--program/urls.py3
-rw-r--r--program/views.py42
-rw-r--r--templates/program/week_schedule.html87
4 files changed, 129 insertions, 4 deletions
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<year>\d{4})/(?P<month>\d{1,2})/(?P<day>\d{1,2})/$', DayScheduleView.as_view()),
+ ('^(?P<year>\d{4})/(?P<week>\d{1,2})/$', WeekScheduleView.as_view()),
('^current/$', CurrentShowView.as_view()),
('^hosts/$', ListView.as_view(model=Host, context_object_name='hosts')),
url('^host/(?P<pk>\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 @@
+<html>
+<head>
+ <title>Week schedule</title>
+</head>
+
+<body>
+
+<div id="week-schedule">
+ <div id="time">
+ <div class="1hour">06:00</div>
+ <div class="1hour">07:00</div>
+ <div class="1hour">08:00</div>
+ <div class="1hour">09:00</div>
+ <div class="1hour">10:00</div>
+ <div class="1hour">11:00</div>
+ <div class="1hour">12:00</div>
+ <div class="1hour">13:00</div>
+ <div class="1hour">14:00</div>
+ <div class="1hour">15:00</div>
+ <div class="1hour">16:00</div>
+ <div class="1hour">17:00</div>
+ <div class="1hour">18:00</div>
+ <div class="1hour">19:00</div>
+ <div class="1hour">20:00</div>
+ <div class="1hour">21:00</div>
+ <div class="1hour">22:00</div>
+ <div class="1hour">23:00</div>
+ <div class="1hour">00:00</div>
+ <div class="1hour">01:00</div>
+ <div class="1hour">02:00</div>
+ <div class="1hour">03:00</div>
+ <div class="1hour">04:00</div>
+ <div class="1hour">05:00</div>
+ </div>
+
+ <div id="monday">
+ <div class="weekday">{{ monday|date:"l d.m.Y" }}</div>
+ {% for timeslot in monday_timeslots %}
+ <div class="timeslot {{ timeslot.show.broadcastformat.slug }}"><a href="{% url timeslot-detail timeslot.id %}">{{ timeslot.show.name }}</a></div>
+ {% endfor %}
+ </div>
+
+ <div id="tuesday">
+ <div class="weekday">{{ tuesday|date:"l d.m.Y" }}</div>
+ {% for timeslot in tuesday_timeslots %}
+ <div class="timeslot {{ timeslot.show.broadcastformat.slug }}"><a href="{% url timeslot-detail timeslot.id %}">{{ timeslot.show.name }}</a></div>
+ {% endfor %}
+ </div>
+
+ <div id="wednesday">
+ <div class="weekday">{{ wednesday|date:"l d.m.Y" }}</div>
+ {% for timeslot in wednesday_timeslots %}
+ <div class="timeslot {{ timeslot.show.broadcastformat.slug }}"><a href="{% url timeslot-detail timeslot.id %}">{{ timeslot.show.name }}</a></div>
+ {% endfor %}
+ </div>
+
+ <div id="thursday">
+ <div class="weekday">{{ thursday|date:"l d.m.Y" }}</div>
+ {% for timeslot in thursday_timeslots %}
+ <div class="timeslot {{ timeslot.show.broadcastformat.slug }}"><a href="{% url timeslot-detail timeslot.id %}">{{ timeslot.show.name }}</a></div>
+ {% endfor %}
+ </div>
+
+ <div id="friday">
+ <div class="weekday">{{ friday|date:"l d.m.Y" }}</div>
+ {% for timeslot in friday_timeslots %}
+ <div class="timeslot {{ timeslot.show.broadcastformat.slug }}"><a href="{% url timeslot-detail timeslot.id %}">{{ timeslot.show.name }}</a></div>
+ {% endfor %}
+ </div>
+
+ <div id="saturday">
+ <div class="weekday">{{ saturday|date:"l d.m.Y" }}</div>
+ {% for timeslot in saturday_timeslots %}
+ <div class="timeslot {{ timeslot.show.broadcastformat.slug }}"><a href="{% url timeslot-detail timeslot.id %}">{{ timeslot.show.name }}</a></div>
+ {% endfor %}
+ </div>
+
+ <div id="sunday">
+ <div class="weekday">{{ sunday|date:"l d.m.Y" }}</div>
+ {% for timeslot in sunday_timeslots %}
+ <div class="timeslot {{ timeslot.show.broadcastformat.slug }}"><a href="{% url timeslot-detail timeslot.id %}">{{ timeslot.show.name }}</a></div>
+ {% endfor %}
+ </div>
+</div>
+
+</body>
+</html>