diff options
Diffstat (limited to 'program/urls.py')
-rw-r--r-- | program/urls.py | 62 |
1 files changed, 20 insertions, 42 deletions
diff --git a/program/urls.py b/program/urls.py index 328f4a1..18625a4 100644 --- a/program/urls.py +++ b/program/urls.py @@ -1,51 +1,29 @@ from django.conf import settings -from django.conf.urls.defaults import * +from django.conf.urls import patterns, url from django.views.decorators.cache import cache_page -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, week_schedule, styles +import views -from datetime import date +import os -hosts_dict = { - 'queryset': Host.objects.filter(shows__programslots__until__gte=date.today()).distinct(), - 'template_object_name': 'host' -} -shows_dict = { - 'queryset': Show.objects.all(), - 'template_object_name': 'show' -} -timeslots_dict = { - 'queryset': TimeSlot.objects.all(), - 'template_object_name': 'timeslot' -} -recommendations_dict = {'template_name': 'boxes/recommendations.html'} +PROGRAM_SITE_MEDIA = os.path.join(os.path.dirname(__file__), '../site_media') -urlpatterns = patterns('', - url(r'^today/?$', day_schedule), - url(r'^(?P<year>\d{4})/(?P<month>\d{1,2})/(?P<day>\d{1,2})/?$', day_schedule), - url(r'^(?P<year>\d{4})/(?P<week>\d{1,2})/?$', week_schedule), - url(r'^current_box/?$', cache_page(current_show, 60)), - url(r'^hosts/?$', object_list, dict(hosts_dict, template_name='host_list.html')), - url(r'^hosts/(?P<object_id>\d+)/?$', object_detail, - dict(hosts_dict, template_name='host_detail.html'), name='host-detail'), - url(r'^tips/?$', recommendations), - url(r'^tips_box/?$', recommendations, recommendations_dict), - url(r'^shows/?$', show_list), - url(r'^shows/(?P<slug>[\w-]+)/?$', object_detail, dict(shows_dict, template_name='show_detail.html'), - name='show-detail'), - url(r'^(?P<object_id>\d+)/?$', object_detail, - dict(timeslots_dict, template_name='timeslot_detail.html'), name='timeslot-detail'), - url(r'^week/?$', week_schedule), - url(r'^styles.css$', styles), -) +urlpatterns = patterns('', + url(r'^today/?$', views.DayScheduleView.as_view()), + url(r'^week/?$', views.WeekScheduleView.as_view()), + url(r'^(?P<year>\d{4})/(?P<month>\d{1,2})/(?P<day>\d{1,2})/?$', views.DayScheduleView.as_view()), + url(r'^(?P<year>\d{4})/(?P<week>\d{1,2})/?$', views.WeekScheduleView.as_view()), + url(r'^current_box/?$', cache_page(60)(views.CurrentShowBoxView.as_view())), + url(r'^hosts/?$', views.HostListView.as_view()), + url(r'^hosts/(?P<pk>\d+)/?$', views.HostDetailView.as_view(), name='host-detail'), + url(r'^tips/?$', views.RecommendationsListView.as_view()), + url(r'^tips_box/?$', views.RecommendationsBoxView.as_view()), + url(r'^shows/?$', views.ShowListView.as_view()), + url(r'^shows/(?P<slug>[\w-]+)/?$', views.ShowDetailView.as_view(), name='show-detail'), + url(r'^(?P<pk>\d+)/?$', views.TimeSlotDetailView.as_view(), name='timeslot-detail'), + url(r'^styles.css$', views.StylesView.as_view()) + ) if settings.DEBUG: - import os - - PROGRAM_STATIC_DIR = os.path.join(os.path.dirname(__file__), '../site_media') urlpatterns += patterns('', - url(r'^static/(?P<path>.*)$', 'django.views.static.serve', - {'document_root': PROGRAM_STATIC_DIR}), - ) + url(r'^static/(?P<path>.*)$', 'django.views.static.serve', {'document_root': PROGRAM_SITE_MEDIA})) |