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 and compete in interschool soccer matches" ,
44+ "schedule" : "Tuesdays and Thursdays, 4:00 PM - 5:30 PM" ,
45+ "max_participants" : 25 ,
46+ "participants" : ["alex@mergington.edu" , "mia@mergington.edu" ]
47+ },
48+ "Swimming Club" : {
49+ "description" : "Swimming lessons and competitive training" ,
50+ "schedule" : "Wednesdays, 3:30 PM - 5:00 PM" ,
51+ "max_participants" : 15 ,
52+ "participants" : ["lucas@mergington.edu" ]
53+ },
54+ "Art Studio" : {
55+ "description" : "Explore painting, drawing, and mixed media art" ,
56+ "schedule" : "Mondays, 3:30 PM - 5:00 PM" ,
57+ "max_participants" : 18 ,
58+ "participants" : ["isabella@mergington.edu" , "ava@mergington.edu" ]
59+ },
60+ "Drama Club" : {
61+ "description" : "Acting, theater production, and performance arts" ,
62+ "schedule" : "Thursdays, 4:00 PM - 6:00 PM" ,
63+ "max_participants" : 20 ,
64+ "participants" : ["noah@mergington.edu" ]
65+ },
66+ "Debate Team" : {
67+ "description" : "Develop critical thinking and public speaking skills" ,
68+ "schedule" : "Wednesdays, 3:30 PM - 5:00 PM" ,
69+ "max_participants" : 16 ,
70+ "participants" : ["liam@mergington.edu" , "charlotte@mergington.edu" ]
71+ },
72+ "Science Olympiad" : {
73+ "description" : "Compete in science and engineering challenges" ,
74+ "schedule" : "Fridays, 3:30 PM - 5:30 PM" ,
75+ "max_participants" : 15 ,
76+ "participants" : ["ethan@mergington.edu" ]
4177 }
4278}
4379
@@ -62,6 +98,11 @@ def signup_for_activity(activity_name: str, email: str):
6298 # Get the specific activity
6399 activity = activities [activity_name ]
64100
101+
102+ # Validate student is not already signed up
103+ if email in activity ["participants" ]:
104+ raise HTTPException (status_code = 400 , detail = "Student already signed up for this activity" )
105+
65106 # Add student
66107 activity ["participants" ].append (email )
67108 return {"message" : f"Signed up { email } for { activity_name } " }
0 commit comments