Commit fcdd3f64 authored by fred's avatar fred
Browse files

update grid to get nonstop periods from database

parent 60e32e04
...@@ -7,7 +7,8 @@ from django.views.decorators.csrf import csrf_exempt ...@@ -7,7 +7,8 @@ from django.views.decorators.csrf import csrf_exempt
from jsonresponse import to_json from jsonresponse import to_json
from emissions.models import Emission, Episode, Diffusion, SoundFile, Schedule, NewsItem, NewsCategory from emissions.models import Emission, Episode, Diffusion, SoundFile, \
Schedule, Nonstop, NewsItem, NewsCategory
from emissions.utils import whatsonair from emissions.utils import whatsonair
...@@ -72,17 +73,22 @@ class Grid(TemplateView): ...@@ -72,17 +73,22 @@ class Grid(TemplateView):
# start grid after the night programs # start grid after the night programs
times = times[2*Schedule.DAY_HOUR_START:] + times[:2*Schedule.DAY_HOUR_START] times = times[2*Schedule.DAY_HOUR_START:] + times[:2*Schedule.DAY_HOUR_START]
nonstops = [[0, 2, 'Biodiversite'], nonstops = []
[2, 5, 'Reveries'], for nonstop in Nonstop.objects.all():
[5, 7.5, 'La Panique'], if nonstop.start < nonstop.end:
[7.5, 10, 'Matin tranquille'], nonstops.append([nonstop.start.hour + nonstop.start.minute/60.,
[10, 12, 'Up Beat Tempo'], nonstop.end.hour + nonstop.end.minute/60.,
[12, 13, 'L\'heure de pointe'], nonstop.title])
[13, 16, 'Le Mange Disque'], else:
[16, 19, 'Hop Bop and co'], # crossing midnight
[19, 22, 'Acouphene'], nonstops.append([nonstop.start.hour + nonstop.start.minute/60.,
[22, 24, 'Biodiversite'] 24,
] nonstop.title])
nonstops.append([0,
nonstop.end.hour + nonstop.end.minute/60.,
nonstop.title])
nonstops.sort()
print nonstops
for i in range(nb_lines): for i in range(nb_lines):
grid.append([]) grid.append([])
...@@ -92,8 +98,11 @@ class Grid(TemplateView): ...@@ -92,8 +98,11 @@ class Grid(TemplateView):
nonstop = [x for x in nonstops if i>=x[0]*2 and i<x[1]*2][0] nonstop = [x for x in nonstops if i>=x[0]*2 and i<x[1]*2][0]
for time_cell in grid[-1]: for time_cell in grid[-1]:
time_cell.nonstop = nonstop[2] time_cell.nonstop = nonstop[2]
if nonstop[2] == 'Reveries': if nonstop[1] == 5:
time_cell.time_label = '02:00-05:00' # the one ending at 5am will be cut down, so we inscribe
# its duration manually
time_cell.time_label = '%02d:00-%02d:00' % (
nonstop[0], nonstop[1])
for schedule in Schedule.objects.all(): for schedule in Schedule.objects.all():
row_start = schedule.datetime.hour * 2 + \ row_start = schedule.datetime.hour * 2 + \
......
Markdown is supported
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