check weeks & filter doubles out

pull/84/head
Stijn De Clercq 2020-11-03 14:43:49 +01:00
parent cec78f0d5f
commit ec30228929
1 changed files with 12 additions and 1 deletions

View File

@ -61,13 +61,23 @@ class Course:
if slot.day != day: if slot.day != day:
continue continue
# TODO check weeks & filter slots down # This is a special slot that should only be added
# if the week corresponds
if slot.weeks and week not in slot.weeks:
continue
if slot.special: if slot.special:
specials.append(slot) specials.append(slot)
else: else:
slots.append(slot) slots.append(slot)
# Filter doubles out (special classes, ...)
for special in specials:
for slot in slots:
if slot.start == special.start and slot.end == special.end:
slots.remove(slot)
return slots, specials
# TODO add an is_online field to the JSON to allow toggling # TODO add an is_online field to the JSON to allow toggling
@ -79,6 +89,7 @@ class Slot:
self.day = slot["time"][0] self.day = slot["time"][0]
self.start = timeFromInt(slot["time"][1]) self.start = timeFromInt(slot["time"][1])
self.end = timeFromInt(slot["time"][2]) self.end = timeFromInt(slot["time"][2])
self.weeks = [] if "weeks" not in slot else slot["weeks"]
self.canceled = "canceled" in slot # Boolean indicating whether or not this class has been canceled self.canceled = "canceled" in slot # Boolean indicating whether or not this class has been canceled
self.special = "weeks" in slot or self.canceled # Boolean indicating if this class is special or generic self.special = "weeks" in slot or self.canceled # Boolean indicating if this class is special or generic