Commit 95b0d81e authored by fred's avatar fred

add time labels when it doesn't match actual cell

parent 2a269ef5
......@@ -191,12 +191,28 @@ class Grid(TemplateView):
# this handles case A (see comment above)
for schedule in current_cell_schedules:
if schedule in same_cell_below.schedules:
print 'removing schedule:', schedule
same_cell_below.schedules.remove(schedule)
elif same_cell_below.schedules and \
current_cell_schedules.issuperset(same_cell_below.schedules):
# this handles case B (see comment above)
# we set the cell time label to the longest
# period
grid[i][j].time_label = same_cell_below.time_label
# then we sort emissions so the longest are
# put first
grid[i][j].schedules.sort(
lambda x, y: -cmp(x.get_duration(), y.get_duration()))
# then we add individual time labels to the
# other schedules
for schedule in current_cell_schedules:
if schedule not in same_cell_below.schedules:
end_time = schedule.datetime + timedelta(
minutes=schedule.get_duration())
schedule.time_label = '%02d:%02d-%02d:%02d' % (
schedule.datetime.hour,
schedule.datetime.minute,
end_time.hour,
end_time.minute)
grid[i][j].h += 1
grid[i+cursor].remove(same_cell_below)
cursor += 1
......
......@@ -47,8 +47,19 @@
<strong>
<a href="{% url 'emission-view' slug=schedule.emission.slug %}">{{ schedule.emission.title }}</a>
</strong>
<br />{% if schedule.weeks_string %}
({{ schedule.weeks_string }})
<br />
{% if schedule.weeks_string or schedule.time_label %}
{% spaceless %}
<span>(</span>
{% if schedule.time_label %}
<span>{{ schedule.time_label }}</span>
{% if schedule.weeks_string %}<span>, </span>{% endif %}
{% endif %}
{% if schedule.weeks_string %}
<span>{{ schedule.weeks_string }}</span>
{% endif %}
<span>)</span>
{% endspaceless %}
{% endif %}
</div>
{% endfor %}
......
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