diff --git a/web/evdata_processor.py b/web/evdata_processor.py index 08db627..0fa62a6 100644 --- a/web/evdata_processor.py +++ b/web/evdata_processor.py @@ -17,11 +17,11 @@ def __init__(self, calendar_name: str, *args, **kwargs): name="X-WR-CALNAME", value=calendar_name)) -def process_class_evdata(events: list) -> str: +def process_class_evdata(events: list, calendar_name: str) -> str: def preprocess_time(s: str): return arrow.get(s, "YYYY-M-D HH:mm:ss", tzinfo=TIMEZONE) - calendar = NamedCalendar("SIMASTER Classes") + calendar = NamedCalendar(calendar_name) for event_data in events: e = Event() @@ -34,7 +34,7 @@ def preprocess_time(s: str): return str(calendar) -def process_exam_evdata(exam_tables: list) -> str: +def process_exam_evdata(exam_tables: list, calendar_name: str) -> str: def preprocess_str(s: str): if not isinstance(s, str) and not s: return None diff --git a/web/views.py b/web/views.py index 82a4766..3c5e7d1 100644 --- a/web/views.py +++ b/web/views.py @@ -33,12 +33,16 @@ def get_icalendar(): if not ses: return {"error": "Invalid username or password"}, 401 + title_suffix = f"({username} / {period})" + if type_ == "class": evdata = get_class_evdata(ses, period) - ics_str = process_class_evdata(evdata) + ics_str = process_class_evdata( + evdata, f"SIMASTER Classes {title_suffix}") elif type_ == "exam": evdata = get_exam_evdata(ses, period) - ics_str = process_exam_evdata(evdata) + ics_str = process_exam_evdata( + evdata, f"SIMASTER Exams {title_suffix}") else: return {"error": "Invalid type"}, 401