program: hide empty rooms

This commit is contained in:
Élie Bouttier 2016-10-17 14:22:34 +02:00
parent 7cd62940c3
commit 6c42449330

View File

@ -17,14 +17,18 @@ Event = namedtuple('Event', ['talk', 'row', 'rowcount'])
class Program: class Program:
def __init__(self, site): def __init__(self, site, empty_rooms=False):
self.rooms = Room.objects.filter(site=site)
self.talks = Talk.objects.\ self.talks = Talk.objects.\
filter(site=site, room__in=self.rooms.all(), start_date__isnull=False).\ filter(site=site, room__isnull=False, start_date__isnull=False).\
filter(Q(duration__gt=0) | Q(event__duration__gt=0)).\ filter(Q(duration__gt=0) | Q(event__duration__gt=0)).\
exclude(accepted=False).\ exclude(accepted=False).\
order_by('start_date') order_by('start_date')
if empty_rooms:
self.rooms = Room.objects.filter(site=site)
else:
self.rooms = Room.objects.filter(talk__in=self.talks.all()).order_by('name').distinct()
self.timeslots = [] self.timeslots = []
for talk in self.talks.all(): for talk in self.talks.all():
duration = talk.estimated_duration() duration = talk.estimated_duration()