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
"""
special = False
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"])
start_time = slot_dict["time"]["start"]
@ -71,16 +81,9 @@ class Timeslot:
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
return Timeslot(course=course, start_time=start_time, end_time=end_time, canceled=False, is_special=False,
location=location, online_platform=online_platform, online_link=online_link)
return Timeslot(course=course, start_time=start_time, end_time=end_time, canceled="canceled" in slot_dict,
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
class Schedule:
@ -145,8 +148,8 @@ class Schedule:
"""
Load the schedule from the JSON file
"""
semester = get_platform("semester")
year = get_platform("year")
semester = get("semester")
year = get("year")
with open(f"files/schedules/{year}{semester}.json", "r") as fp:
return json.load(fp)

View File

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