Commit fcdd3f64 authored by fred's avatar fred

update grid to get nonstop periods from database

parent 60e32e04
......@@ -7,7 +7,8 @@ from django.views.decorators.csrf import csrf_exempt
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
......@@ -72,17 +73,22 @@ class Grid(TemplateView):
# start grid after the night programs
times = times[2*Schedule.DAY_HOUR_START:] + times[:2*Schedule.DAY_HOUR_START]
nonstops = [[0, 2, 'Biodiversite'],
[2, 5, 'Reveries'],
[5, 7.5, 'La Panique'],
[7.5, 10, 'Matin tranquille'],
[10, 12, 'Up Beat Tempo'],
[12, 13, 'L\'heure de pointe'],
[13, 16, 'Le Mange Disque'],
[16, 19, 'Hop Bop and co'],
[19, 22, 'Acouphene'],
[22, 24, 'Biodiversite']
]
nonstops = []
for nonstop in Nonstop.objects.all():
if nonstop.start < nonstop.end:
nonstops.append([nonstop.start.hour + nonstop.start.minute/60.,
nonstop.end.hour + nonstop.end.minute/60.,
nonstop.title])
else:
# crossing midnight
nonstops.append([nonstop.start.hour + nonstop.start.minute/60.,
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):
grid.append([])
......@@ -92,8 +98,11 @@ class Grid(TemplateView):
nonstop = [x for x in nonstops if i>=x[0]*2 and i<x[1]*2][0]
for time_cell in grid[-1]:
time_cell.nonstop = nonstop[2]
if nonstop[2] == 'Reveries':
time_cell.time_label = '02:00-05:00'
if nonstop[1] == 5:
# 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():
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