Commit c717c35a authored by fred's avatar fred
Browse files

add a json view with what's on air

parent 92652431
......@@ -9,6 +9,7 @@ admin.autodiscover()
urlpatterns = patterns('',
url(r'^$', 'panikweb.views.home', name='home'),
url(r'^onair.json$', 'panikweb.views.onair', name='onair'),
url(r'^program$', 'panikweb.views.program', name='program'),
url(r'^grid$', 'panikweb.views.grid', name='grid'),
url(r'^emissions/', include('emissions.urls')),
......@@ -2,8 +2,12 @@ from datetime import datetime, timedelta
import math
from django.views.generic.base import TemplateView
from django.views.decorators.csrf import csrf_exempt
from jsonresponse import to_json
from emissions.models import Emission, Episode, Diffusion, SoundFile, Schedule
from emissions.utils import whatsonair
class ProgramView(TemplateView):
template_name = 'program.html'
......@@ -211,3 +215,18 @@ class Player(TemplateView):
player = Player.as_view()
def onair(request):
d = whatsonair()
if d.get('episode'):
d['episode'] = {
'title': d['episode'].title,
'url': d['episode'].get_absolute_url()
if d.get('emission'):
d['emission'] = {
'title': d['emission'].title,
'url': d['emission'].get_absolute_url()
return d
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment