Skip to content

Commit

Permalink
feat: add username and period to cal title
Browse files Browse the repository at this point in the history
Signed-off-by: Faiz Jazadi <[email protected]>
  • Loading branch information
lc-at committed Feb 23, 2023
1 parent 3459785 commit fa2864a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
6 changes: 3 additions & 3 deletions web/evdata_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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
Expand Down
8 changes: 6 additions & 2 deletions web/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit fa2864a

Please sign in to comment.