Skip to content

Commit a2fd2b4

Browse files
committed
Add extracurricular activities and signup validation
1 parent b7aee45 commit a2fd2b4

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+
"Basketball Team": {
43+
"description": "Join the school basketball team and compete in local leagues",
44+
"schedule": "Mondays and Wednesdays, 4:00 PM - 6:00 PM",
45+
"max_participants": 15,
46+
"participants": ["liam@mergington.edu"]
47+
},
48+
"Soccer Club": {
49+
"description": "Practice soccer skills and play friendly matches",
50+
"schedule": "Tuesdays and Thursdays, 4:00 PM - 5:30 PM",
51+
"max_participants": 18,
52+
"participants": ["noah@mergington.edu"]
53+
},
54+
"Art Club": {
55+
"description": "Explore painting, drawing, and other visual arts",
56+
"schedule": "Fridays, 3:30 PM - 5:00 PM",
57+
"max_participants": 10,
58+
"participants": ["ava@mergington.edu"]
59+
},
60+
"Drama Society": {
61+
"description": "Participate in school plays and drama workshops",
62+
"schedule": "Wednesdays, 3:30 PM - 5:00 PM",
63+
"max_participants": 20,
64+
"participants": ["mia@mergington.edu"]
65+
},
66+
"Math Olympiad": {
67+
"description": "Prepare for math competitions and solve challenging problems",
68+
"schedule": "Thursdays, 3:30 PM - 4:30 PM",
69+
"max_participants": 12,
70+
"participants": ["lucas@mergington.edu"]
71+
},
72+
"Debate Club": {
73+
"description": "Develop public speaking and argumentation skills",
74+
"schedule": "Mondays, 3:30 PM - 5:00 PM",
75+
"max_participants": 16,
76+
"participants": ["charlotte@mergington.edu"]
4177
}
4278
}
4379

@@ -63,5 +99,9 @@ def signup_for_activity(activity_name: str, email: str):
6399
activity = activities[activity_name]
64100

65101
# Add student
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+
66106
activity["participants"].append(email)
67107
return {"message": f"Signed up {email} for {activity_name}"}

0 commit comments

Comments
 (0)