summaryrefslogtreecommitdiff
path: root/helsinki/program/views.py
diff options
context:
space:
mode:
authorErnesto Rico-Schmidt <e.rico.schmidt@gmail.com>2011-04-10 16:21:44 (GMT)
committerErnesto Rico-Schmidt <e.rico.schmidt@gmail.com>2011-04-10 16:21:44 (GMT)
commitbb852483864a5c1be8cd99d2e05a3b1fc0ce0d5c (patch)
treee676cccf187ff89735c585142586c28fb4b326e1 /helsinki/program/views.py
parent055afc7d47fcd147274dba884156523d8ff69bbf (diff)
cleaned-up URL and views. implemented /week URL.
Diffstat (limited to 'helsinki/program/views.py')
-rw-r--r--helsinki/program/views.py47
1 files changed, 13 insertions, 34 deletions
diff --git a/helsinki/program/views.py b/helsinki/program/views.py
index 584f24d..48b5d5f 100644
--- a/helsinki/program/views.py
+++ b/helsinki/program/views.py
@@ -33,7 +33,6 @@ def show_list(request):
else:
queryset = Show.objects.all()
-
return list_detail.object_list(request, queryset=queryset, extra_context=extra_context, template_object_name='show')
def recommendations(request, template_name='program/recommendations.html'):
@@ -44,13 +43,16 @@ def recommendations(request, template_name='program/recommendations.html'):
return list_detail.object_list(request, queryset=queryset, template_name=template_name, template_object_name='recommendation')
-def today_schedule(request):
- now = datetime.now()
- today = datetime.combine(date.today(), time(6, 0))
- tomorrow = today + timedelta(days=1)
+def day_schedule(request, year=None, month=None, day=None):
+ if year is None and month is None and day is None:
+ today = datetime.combine(date.today(), time(6, 0))
+ else:
+ today = datetime.strptime('%s__%s__%s__06__00' % (year, month, day), '%Y__%m__%d__%H__%M')
+
+ tomorrow = today+timedelta(days=1)
broadcastformats = BroadcastFormat.objects.all()
- recommendations = Note.objects.filter(status=1, timeslot__start__range=(now, tomorrow))
+ recommendations = Note.objects.filter(status=1, timeslot__start__range=(today, tomorrow))
extra_context = dict(day=today, broadcastformats=broadcastformats, recommendations=recommendations)
@@ -63,24 +65,6 @@ def today_schedule(request):
return simple.direct_to_template(request, extra_context=extra_context, template='program/day_schedule.html')
-def day_schedule(request, year, month, day):
- this_day = datetime.strptime('%s__%s__%s__06__00' % (year, month, day), '%Y__%m__%d__%H__%M')
- that_day = this_day+timedelta(days=1)
-
- broadcastformats = BroadcastFormat.objects.all()
- recommendations = Note.objects.filter(status=1, timeslot__start__range=(this_day, that_day))
-
- extra_context = dict(day=this_day, broadcastformats=broadcastformats, recommendations=recommendations)
-
- if 'broadcastformat' in request.GET:
- broadcastformat = get_object_or_404(BroadcastFormat, slug=request.GET['broadcastformat'])
-
- extra_context['timeslots'] = TimeSlot.objects.filter(start__range=(this_day, that_day), show__broadcastformat=broadcastformat)
- else:
- extra_context['timeslots'] = TimeSlot.objects.filter(start__range=(this_day, that_day))
-
- return simple.direct_to_template(request, extra_context=extra_context, template='program/day_schedule.html')
-
def current_show(request):
current = TimeSlot.objects.get_or_create_current()
next = current.get_next_by_start()
@@ -90,8 +74,12 @@ def current_show(request):
return simple.direct_to_template(request, template='program/current_box.html', extra_context=extra_context)
-def week_schedule(request, year, week):
+def week_schedule(request, year=None, week=None):
+ if year is None and week is None:
+ year, week = datetime.strftime(datetime.today(), '%Y__%W').split('__')
+
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)
@@ -111,12 +99,3 @@ def week_schedule(request, year, week):
extra_context['sunday_timeslots'] = TimeSlot.objects.filter(start__range=(sunday, next_monday))
return simple.direct_to_template(request, template='program/week_schedule.html', extra_context=extra_context)
-
-
-def bcformats(request):
- broadcastformats = BroadcastFormat.objects.all()
- extra_context = dict(broadcastformats=broadcastformats)
- return simple.direct_to_template(
- request,
- template='program/bcformats_box.html',
- extra_context=extra_context)