diff options
author | Christian Pointner <equinox@helsinki.at> | 2017-04-07 00:40:57 (GMT) |
---|---|---|
committer | Christian Pointner <equinox@helsinki.at> | 2017-04-07 00:40:57 (GMT) |
commit | 8ee4333919acd638d2f1a011c287fc4bad88f166 (patch) | |
tree | f72619bedd7d4cf553a0bd2a2cd0db6ea8cfd04a /program/views.py | |
parent | 9f9c557d6c2f741025b44d12669772a9194c25ca (diff) | |
parent | 6eabfdd69ecf3b7615e9522ae3839554afc72864 (diff) |
Merge branch 'master' into stable
Diffstat (limited to 'program/views.py')
-rw-r--r-- | program/views.py | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/program/views.py b/program/views.py index 53467cd..9886d08 100644 --- a/program/views.py +++ b/program/views.py @@ -10,7 +10,7 @@ from django.views.generic.list import ListView from models import BroadcastFormat, MusicFocus, Note, Show, ShowInformation, ShowTopic, TimeSlot, Host -from program.utils import tofirstdayinisoweek +from program.utils import tofirstdayinisoweek, get_cached_shows class HostListView(ListView): @@ -211,3 +211,21 @@ def json_day_schedule(request, year=None, month=None, day=None): return HttpResponse(json.dumps(schedule, ensure_ascii=False, encoding='utf8').encode('utf8'), content_type="application/json; charset=utf-8") + +def json_timeslots_specials(request): + specials = {} + shows = get_cached_shows()['shows'] + for show in shows: + show['pv_id'] = -1 + if show['type'] == 's': + specials[show['id']] = show + + for ts in TimeSlot.objects.filter(end__gt=datetime.now).filter(programslot__automation_id__in=specials.iterkeys()): + automation_id = ts.programslot.automation_id + specials[automation_id]['pv_id'] = int(ts.programslot.show.id) + specials[automation_id]['pv_name'] = ts.programslot.show.name + specials[automation_id]['pv_start'] = ts.start.strftime('%Y-%m-%d_%H:%M:%S') + specials[automation_id]['pv_end'] = ts.end.strftime('%Y-%m-%d_%H:%M:%S') + + return HttpResponse(json.dumps(specials, ensure_ascii=False, encoding='utf8').encode('utf8'), + content_type="application/json; charset=utf-8") |