Commit f27d61fd authored by fred's avatar fred
Browse files

grid: use new durations and week numbers to add more info

parent 9b9e774e
......@@ -25,18 +25,26 @@ class TimeCell:
nonstop = None
w = 1
h = 1
time_label = None
def __init__(self, i, j):
self.x = i
self.y = j
self.emissions = []
def add_emission(self, emission):
self.emissions.append(emission)
self.schedules = []
def add_schedule(self, schedule):
end_time = schedule.datetime + datetime.timedelta(
minutes=schedule.emission.duration)
self.time_label = '%02d:%02d-%02d:%02d' % (
schedule.datetime.hour,
schedule.datetime.minute,
end_time.hour,
end_time.minute)
self.schedules.append(schedule)
def __unicode__(self):
if self.emissions:
return ', '.join([x.title for x in self.emissions])
if self.schedules:
return ', '.join([x.emission.title for x in self.schedules])
else:
return self.nonstop
......@@ -87,7 +95,7 @@ class Grid(TemplateView):
for step in range(int(math.ceil(schedule.emission.duration / 30))):
if grid[(row_start+step)%nb_lines][day_no] is None:
grid[(row_start+step)%nb_lines][day_no] = TimeCell()
grid[(row_start+step)%nb_lines][day_no].add_emission(schedule.emission)
grid[(row_start+step)%nb_lines][day_no].add_schedule(schedule)
# start grid at 5am
grid = grid[2*5:] + grid[:2*5]
......
......@@ -30,6 +30,10 @@
font-size:15px;
}
#grille h3 {
width: 100%;
}
#grille .jour {
margin-top:20px;
margin-bottom:30px;
......@@ -65,7 +69,20 @@
<td class="heure">{{ time_header }}</td>
{% for cell in time_cells %}
<td {% if cell.w > 1 %}colspan="{{cell.w}}"{% endif %}
{% if cell.h > 1 %}rowspan="{{cell.h}}"{% endif %}>{{ cell }}</td>
{% if cell.h > 1 %}rowspan="{{cell.h}}"{% endif %}>
{% if cell.time_label %}<h5>{{ cell.time_label }}</h5>{% endif %}
{% if cell.schedules %}
{% for schedule in cell.schedules %}
<h4>{{ schedule.emission.title }}</h4>
{% if schedule.weeks_string %}
({{ schedule.weeks_string }})
{% endif %}
{% endfor %}
{% else %}
<h3 class="continu">{{ cell }}</h3>
{% if cell.w > 1 and cell.h > 1%}<p>la musique en continu</p>{% endif %}
{% endif %}
</td>
{% endfor %}
<td class="heure">{{ time_header }}</td>
</tr>
......
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