If there are no track names for today, don't show the row

If there are track names today, show the row for track names. If there aren't, don't show an empty row.
This commit is contained in:
James Polley 2017-12-03 15:23:46 +11:00
parent bc3edb80d9
commit cfc19f309f
2 changed files with 20 additions and 8 deletions

View file

@ -7,6 +7,8 @@
<th>{{ room.name }}</th> <th>{{ room.name }}</th>
{% endfor %} {% endfor %}
</tr> </tr>
{% with timetable|day_has_tracks:timetable.day as has_tracks %}
{% if has_tracks %}
<tr> <tr>
<th class="time">&nbsp;</th> <th class="time">&nbsp;</th>
{% for room in timetable.rooms %} {% for room in timetable.rooms %}
@ -15,6 +17,8 @@
{% endwith %} {% endwith %}
{% endfor %} {% endfor %}
</tr> </tr>
{% endif %}
{% endwith %}
</thead> </thead>
<tbody> <tbody>
{% for row in timetable %} {% for row in timetable %}

View file

@ -78,6 +78,14 @@ def gst(amount):
def conference_name(): def conference_name():
return conference_models.Conference.objects.get(id=CONFERENCE_ID).title return conference_models.Conference.objects.get(id=CONFERENCE_ID).title
@register.filter()
def day_has_tracks(timetable, day):
try:
track_names = day.track_set.all()
has_tracks = True
except Track.DoesNotExist:
has_tracks = False
return len(track_names)
@register.filter() @register.filter()
def trackname(room, day): def trackname(room, day):