Commit 5f49a618 authored by fred's avatar fred
Browse files

adjust grid to new dawn time

parent 5a168128
......@@ -293,7 +293,8 @@ class Grid(TemplateView):
times = ['%02d:%02d' % (x/2, x%2*30) for x in range(nb_lines)]
# 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 + (1 if Schedule.DAY_MINUTE_START else 0):] + \
times[: 2 * Schedule.DAY_HOUR_START + (1 if Schedule.DAY_MINUTE_START else 0)]
nonstops = []
for nonstop in Nonstop.objects.all():
......@@ -323,11 +324,11 @@ class Grid(TemplateView):
time_cell.nonstop = nonstop[2]
time_cell.nonstop_slug = nonstop[3]
time_cell.redirect_path = nonstop[4].redirect_path
if nonstop[1] == 5:
# the one ending at 5am will be cut down, so we inscribe
if nonstop[1] == Schedule.DAY_HOUR_START + Schedule.DAY_MINUTE_START / 60:
# the one ending at 4:30am will be cut down, so we inscribe
# its duration manually
time_cell.time_label = '%02d:00-%02d:00' % (
nonstop[0], nonstop[1])
time_cell.time_label = '%02d:00-%02d:%02d' % (
nonstop[0], nonstop[1], Schedule.DAY_MINUTE_START)
for schedule in Schedule.objects.prefetch_related(
'emission__categories').select_related().order_by('datetime'):
......@@ -345,7 +346,8 @@ class Grid(TemplateView):
grid[(row_start+step)%nb_lines][day_no].add_schedule(schedule)
# start grid after the night programs
grid = grid[2*Schedule.DAY_HOUR_START:] + grid[:2*Schedule.DAY_HOUR_START]
grid = grid[2 * Schedule.DAY_HOUR_START + (1 if Schedule.DAY_MINUTE_START else 0):] + \
grid[: 2 * Schedule.DAY_HOUR_START + (1 if Schedule.DAY_MINUTE_START else 0)]
# look for the case where the same emission has different schedules for
# the same time cell, for example if it lasts one hour the first week,
......@@ -380,6 +382,7 @@ class Grid(TemplateView):
for schedule in schedule_list[1:]:
grid[i][j].schedules.remove(schedule)
end_time = schedule.datetime + timedelta(minutes=schedule.get_duration())
# TODO: si tout la même durée, merge possible ?
schedule_list[0].time_label_extra = ', -%02d:%02d %s' % (
end_time.hour, end_time.minute, schedule.weeks_string)
......@@ -498,9 +501,9 @@ class Grid(TemplateView):
except IndexError:
pass
# cut night at 3am
grid = grid[:42]
times = times[:42]
# cut late night hours
grid = grid[:44]
times = times[:44]
context['grid'] = grid
context['times'] = times
......
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