Special weeks

pull/84/head
Stijn De Clercq 2021-08-08 15:18:45 +02:00
parent 1857bdefe9
commit b3854324d4
2 changed files with 22 additions and 19 deletions

View File

@ -57,8 +57,18 @@ class Timeslot:
""" """
Construct a Timeslot from a dict of data Construct a Timeslot from a dict of data
""" """
special = False
if "weeks" in slot_dict and str(current_week) in slot_dict["weeks"]: if "weeks" in slot_dict and str(current_week) in slot_dict["weeks"]:
return Timeslot.special_from_dict(slot_dict, course_dict, str(current_week)) # If at least one thing was changed, this slot requires extra attention
special = True
# Overwrite the normal data with the customized entries
slot_dict.update(slot_dict["weeks"][str(current_week)])
# Only happens online, not on-campus
online_only = slot_dict["weeks"][str(current_week)].get("online_only", False)
if online_only:
slot_dict.pop("location")
course = Course(course_dict["course"]) course = Course(course_dict["course"])
start_time = slot_dict["time"]["start"] start_time = slot_dict["time"]["start"]
@ -71,16 +81,9 @@ class Timeslot:
online_platform: Platform = get_platform(slot_dict.get("online", None)) online_platform: Platform = get_platform(slot_dict.get("online", None))
online_link = course_dict["online_links"][Platform.value["rep"]] if online_platform is not None else None online_link = course_dict["online_links"][Platform.value["rep"]] if online_platform is not None else None
return Timeslot(course=course, start_time=start_time, end_time=end_time, canceled=False, is_special=False, return Timeslot(course=course, start_time=start_time, end_time=end_time, canceled="canceled" in slot_dict,
location=location, online_platform=online_platform, online_link=online_link) is_special=special, location=location, online_platform=online_platform, online_link=online_link)
@staticmethod
def special_from_dict(slot_dict: Dict, course_dict: Dict, current_week: str):
"""
Create a SPECIAL Timeslot from a dict and data
"""
course = Course(course_dict["course"])
# TODO
@dataclass @dataclass
class Schedule: class Schedule:
@ -145,8 +148,8 @@ class Schedule:
""" """
Load the schedule from the JSON file Load the schedule from the JSON file
""" """
semester = get_platform("semester") semester = get("semester")
year = get_platform("year") year = get("year")
with open(f"files/schedules/{year}{semester}.json", "r") as fp: with open(f"files/schedules/{year}{semester}.json", "r") as fp:
return json.load(fp) return json.load(fp)

View File

@ -36,7 +36,7 @@
} }
}, },
{ {
"online": "ZOOM", "online": "zoom",
"time": { "time": {
"day": "vrijdag", "day": "vrijdag",
"start": 1300, "start": 1300,
@ -52,7 +52,7 @@
}, },
"slots": [ "slots": [
{ {
"online": "ZOOM", "online": "zoom",
"time": { "time": {
"day": "dinsdag", "day": "dinsdag",
"start": 1130, "start": 1130,
@ -60,7 +60,7 @@
} }
}, },
{ {
"online": "ZOOM", "online": "zoom",
"time": { "time": {
"day": "woensdag", "day": "woensdag",
"start": 1500, "start": 1500,
@ -68,7 +68,7 @@
} }
}, },
{ {
"online": "ZOOM", "online": "zoom",
"time": { "time": {
"day": "donderdag", "day": "donderdag",
"start": 830, "start": 830,
@ -85,7 +85,7 @@
}, },
"slots": [ "slots": [
{ {
"online": "MS Teams", "online": "msteams",
"time": { "time": {
"day": "dinsdag", "day": "dinsdag",
"start": 1430, "start": 1430,
@ -93,7 +93,7 @@
} }
}, },
{ {
"online": "MS Teams", "online": "msteams",
"time": { "time": {
"day": "vrijdag", "day": "vrijdag",
"start": 830, "start": 830,
@ -126,7 +126,7 @@
} }
}, },
{ {
"online": "ZOOM", "online": "zoom",
"time": { "time": {
"day": "donderdag", "day": "donderdag",
"start": 1000, "start": 1000,