Skip to content

Commit

Permalink
bug(tp+pc): fix multiterm to function correctly when dragged and when…
Browse files Browse the repository at this point in the history
… reporting plannedFor
  • Loading branch information
Peedee2002 committed Aug 17, 2024
1 parent cd736b4 commit b32ea7a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
3 changes: 2 additions & 1 deletion backend/server/routers/planner.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,8 @@ def unschedule(data: CourseCode, uid: Annotated[str, Security(require_uid)]):
if data.courseCode in course_list:
removed = True
course_list.remove(data.courseCode)
user['planner']['unplanned'].append(data.courseCode)
if data.courseCode not in user['planner']['unplanned']:
user['planner']['unplanned'].append(data.courseCode)

if not removed:
raise HTTPException(status_code=400, detail=f'{data.courseCode} not found in planner')
Expand Down
9 changes: 7 additions & 2 deletions backend/server/routers/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,13 @@ def get_user_p(uid: Annotated[str, Security(require_uid)]) -> Dict[str, CourseSt
for index, year in enumerate(planner['years']):
for termIndex, term in year.items():
for course in term:
assert course not in flattened # makes sure its not double storred
flattened[course] = f"{index + planner['startYear']} {termIndex}"
# clunky - needed to convince mypy that this is a safe operation
course_value = flattened.get(course)
if course in flattened and course_value is not None:
# multiterm
flattened[course] = course_value + f", {index + planner['startYear']} {termIndex}"
else:
flattened[course] = f"{index + planner['startYear']} {termIndex}"

res: Dict[str, CourseStorageWithExtra] = {}

Expand Down

0 comments on commit b32ea7a

Please sign in to comment.