Skip to content

Commit e926573

Browse files
committed
Add validation to prevent duplicate sign-ups for activities
1 parent 56d4d71 commit e926573

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

src/app.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ def signup_for_activity(activity_name: str, email: str):
6262
# Get the specific activity
6363
activity = activities[activity_name]
6464

65+
# Validate if student is already signed up
66+
if email in activity["participants"]:
67+
raise HTTPException(status_code=400, detail="Student is already signed up for this activity")
68+
6569
# Add student
6670
activity["participants"].append(email)
6771
return {"message": f"Signed up {email} for {activity_name}"}

0 commit comments

Comments
 (0)