Skip to content

Commit 8a5e38b

Browse files
committed
Add extracurricular activities and signup validation to the API
1 parent 4cce0e9 commit 8a5e38b

1 file changed

Lines changed: 40 additions & 0 deletions

File tree

src/app.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,42 @@
3838
"schedule": "Mondays, Wednesdays, Fridays, 2:00 PM - 3:00 PM",
3939
"max_participants": 30,
4040
"participants": ["john@mergington.edu", "olivia@mergington.edu"]
41+
},
42+
"Soccer Team": {
43+
"description": "Practice teamwork and compete in soccer matches",
44+
"schedule": "Mondays and Thursdays, 4:00 PM - 5:30 PM",
45+
"max_participants": 25,
46+
"participants": ["liam@mergington.edu", "ava@mergington.edu"]
47+
},
48+
"Basketball Club": {
49+
"description": "Train for basketball games and improve coordination",
50+
"schedule": "Wednesdays, 4:00 PM - 5:30 PM",
51+
"max_participants": 18,
52+
"participants": ["noah@mergington.edu", "mia@mergington.edu"]
53+
},
54+
"Art Club": {
55+
"description": "Create paintings, drawings, and mixed-media art",
56+
"schedule": "Tuesdays, 4:00 PM - 5:30 PM",
57+
"max_participants": 15,
58+
"participants": ["isabella@mergington.edu", "lucas@mergington.edu"]
59+
},
60+
"Drama Club": {
61+
"description": "Perform scenes, practice acting, and stage productions",
62+
"schedule": "Fridays, 4:00 PM - 6:00 PM",
63+
"max_participants": 20,
64+
"participants": ["grace@mergington.edu", "zach@mergington.edu"]
65+
},
66+
"Debate Team": {
67+
"description": "Develop public speaking and argumentation skills",
68+
"schedule": "Wednesdays, 5:00 PM - 6:30 PM",
69+
"max_participants": 16,
70+
"participants": ["ella@mergington.edu", "mason@mergington.edu"]
71+
},
72+
"Math Club": {
73+
"description": "Explore math puzzles, competitions, and problem solving",
74+
"schedule": "Thursdays, 3:30 PM - 4:30 PM",
75+
"max_participants": 22,
76+
"participants": ["charlotte@mergington.edu", "ethan@mergington.edu"]
4177
}
4278
}
4379

@@ -62,6 +98,10 @@ def signup_for_activity(activity_name: str, email: str):
6298
# Get the specific activity
6399
activity = activities[activity_name]
64100

101+
# Validate student is not already signed up
102+
if email not in activity["participants"]:
103+
raise HTTPException(status_code=400, detail="Student already signed up for this activity")
104+
65105
# Add student
66106
activity["participants"].append(email)
67107
return {"message": f"Signed up {email} for {activity_name}"}

0 commit comments

Comments
 (0)