summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--helsinki/program/templates/program/broadcastformats_box.html20
-rw-r--r--helsinki/program/templates/program/recommendations_box.html4
-rw-r--r--helsinki/program/urls.py4
-rw-r--r--helsinki/program/urls_program.py50
-rw-r--r--helsinki/program/views.py40
5 files changed, 72 insertions, 46 deletions
diff --git a/helsinki/program/templates/program/broadcastformats_box.html b/helsinki/program/templates/program/broadcastformats_box.html
new file mode 100644
index 0000000..13fb0a9
--- /dev/null
+++ b/helsinki/program/templates/program/broadcastformats_box.html
@@ -0,0 +1,20 @@
+<!doctype html>
+<html>
+<head>
+ <meta charset="utf-8"/>
+ <title>Broadcast Formats</title>
+ <link href="/site_media/styles/base.css" media="screen" rel="stylesheet" type="text/css" />
+</head>
+<body>
+ {% if broadcastformat_list %}
+ <dl id="bcformats" class="portlet program-bcformats">
+ <dt class="portletHeader"><span>Legende</span></dt>
+ {% for broadcastformat in broadcastformat_list %}
+ <dd class="portletItem bcformat bcformat-{{ broadcastformat.slug }}">
+ <a href="?broadcastformat={{ broadcastformat.slug }}">{{ broadcastformat.format }}</a>
+ </dd>
+ {% endfor %}
+ </dl>
+ {% endif %}
+</body>
+</html>
diff --git a/helsinki/program/templates/program/recommendations_box.html b/helsinki/program/templates/program/recommendations_box.html
index 5a0f40d..abcbe03 100644
--- a/helsinki/program/templates/program/recommendations_box.html
+++ b/helsinki/program/templates/program/recommendations_box.html
@@ -6,10 +6,10 @@
<link href="/site_media/styles/base.css" media="screen" rel="stylesheet" type="text/css" />
</head>
<body>
- {% if recommendations %}
+ {% if recommendation_list %}
<dl id="recommendations" class="portlet program-recommendations">
<dt class="portletHeader">Programmhinweise</dt>
- {% for recommendation in recommendations %}
+ {% for recommendation in recommendation_list %}
<dd class="portletItem program-recommendation {{ recommendation.show.broadcastformat.slug }}">
<h3 class="show-name"><a href="{% url show-detail recommendation.show.slug %}">{{ recommendation.show.name }}</a></h3>
<p class="timeslot-start-end">{{ recommendation.timeslot.start|date:"d.m. H:i" }}-{{ recommendation.timeslot.end|date:"H:i" }}</p>
diff --git a/helsinki/program/urls.py b/helsinki/program/urls.py
index 341923b..f90a332 100644
--- a/helsinki/program/urls.py
+++ b/helsinki/program/urls.py
@@ -7,8 +7,8 @@ import os
admin.autodiscover()
urlpatterns = patterns('',
- (r'^admin/', include(admin.site.urls)),
- (r'^program', include('helsinki.program.urls_program')),
+ (r'^admin/', include(admin.site.urls)),
+ (r'^program/', include('helsinki.program.urls_program')),
)
if settings.DEBUG:
urlpatterns += patterns('',
diff --git a/helsinki/program/urls_program.py b/helsinki/program/urls_program.py
index 4f4b981..5462e10 100644
--- a/helsinki/program/urls_program.py
+++ b/helsinki/program/urls_program.py
@@ -2,22 +2,40 @@ from django.conf.urls.defaults import *
from django.views.generic.list_detail import object_detail, object_list
-from models import Host, Show, TimeSlot
-from views import current_show, day_schedule, recommendations, show_list, today_schedule, week_schedule
+from models import BroadcastFormat, Host, Show, TimeSlot
+from views import current_show, day_schedule, recommendations, show_list, week_schedule
+
+host_dict = {
+ 'queryset': Host.objects.all(),
+ 'template_object_name': 'host'
+}
+show_dict = {
+ 'queryset': Show.objects.all(),
+ 'template_object_name': 'show'
+}
+timeslot_dict = {
+ 'queryset': TimeSlot.objects.all(),
+ 'template_object_name': 'timeslot'
+}
+broadcastformart_dict = {
+ 'queryset': BroadcastFormat.objects.all(),
+ 'template_name': 'program/broadcastformats_box.html',
+ 'template_object_name': 'broadcastformat'
+}
+recommendation_dict = {'template_name': 'program/recommendations_box.html'}
urlpatterns = patterns('',
- ('^/today/?$', today_schedule),
- ('^/(?P<year>\d{4})/(?P<month>\d{1,2})/(?P<day>\d{1,2})/?$', day_schedule),
- ('^/(?P<year>\d{4})/(?P<week>\d{1,2})/?$', week_schedule),
- ('^/current_box/?$', current_show),
- ('^/hosts/?$', object_list, dict(template_object_name='host', queryset=Host.objects.all())),
- url('^/hosts/(?P<object_id>\d+)/?$', object_detail, dict(template_object_name='host', queryset=Host.objects.all()), name='host-detail'),
- ('^/tips/?$', recommendations),
- ('^/tips_box/?$', recommendations, dict(template_name='program/recommendations_box.html')),
- ('^/shows/?$', show_list),
- url('^/shows/(?P<slug>[\w-]+)/?$', object_detail, dict(template_object_name='show', queryset=Show.objects.all()), name='show-detail'),
- url('^/(?P<object_id>\d+)/?$', object_detail, dict(template_object_name='timeslot', queryset=TimeSlot.objects.all()), name='timeslot-detail'),
- # TODO: implement
- ('^/week/?$', today_schedule),
- ('^/broadcast_formats/?$', recommendations),
+ (r'^today/?$', day_schedule),
+ (r'^(?P<year>\d{4})/(?P<month>\d{1,2})/(?P<day>\d{1,2})/?$', day_schedule),
+ (r'^(?P<year>\d{4})/(?P<week>\d{1,2})/?$', week_schedule),
+ (r'^current_box/?$', current_show),
+ (r'^hosts/?$', object_list, host_dict),
+ url(r'^hosts/(?P<object_id>\d+)/?$', object_detail, host_dict, name='host-detail'),
+ (r'^tips/?$', recommendations),
+ (r'^tips_box/?$', recommendations, recommendation_dict),
+ (r'^shows/?$', show_list),
+ url(r'^shows/(?P<slug>[\w-]+)/?$', object_detail, show_dict, name='show-detail'),
+ url(r'^(?P<object_id>\d+)/?$', object_detail, timeslot_dict, name='timeslot-detail'),
+ (r'^broadcastformats_box/?$', object_list, broadcastformart_dict,),
+ (r'^week/?$', week_schedule)
)
diff --git a/helsinki/program/views.py b/helsinki/program/views.py
index 1013f15..a9c7b67 100644
--- a/helsinki/program/views.py
+++ b/helsinki/program/views.py
@@ -14,7 +14,7 @@ from helsinki.program.models import (
from datetime import date, datetime, time, timedelta
def show_list(request):
-
+
if 'broadcastformat' in request.GET:
broadcastformat = get_object_or_404(BroadcastFormat, slug=request.GET['broadcastformat'])
@@ -34,7 +34,6 @@ def show_list(request):
else:
queryset = Show.objects.all()
-
return list_detail.object_list(request, queryset=queryset, template_object_name='show')
def recommendations(request, template_name='program/recommendations.html'):
@@ -45,12 +44,15 @@ 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)
- 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, recommendations=recommendations)
@@ -63,23 +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)
-
- recommendations = Note.objects.filter(status=1, timeslot__start__range=(this_day, that_day))
-
- extra_context = dict(day=this_day, 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()
@@ -89,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)
@@ -110,4 +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)
-