Skip to content

Commit 03a4730

Browse files
committed
Add extracurricular activities and signup validation to API
1 parent 4166236 commit 03a4730

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
@@ -21,6 +21,42 @@
2121

2222
# In-memory activity database
2323
activities = {
24+
"Football Club": {
25+
"description": "Join our competitive football team and develop your skills",
26+
"schedule": "Mondays and Wednesdays, 4:00 PM - 5:30 PM",
27+
"max_participants": 25,
28+
"participants": ["alex@mergington.edu"]
29+
},
30+
"Basketball Team": {
31+
"description": "Practice basketball and compete in inter-school tournaments",
32+
"schedule": "Tuesdays and Thursdays, 4:00 PM - 5:30 PM",
33+
"max_participants": 15,
34+
"participants": ["james@mergington.edu"]
35+
},
36+
"Art Club": {
37+
"description": "Explore painting, drawing, and other visual arts",
38+
"schedule": "Wednesdays, 3:30 PM - 5:00 PM",
39+
"max_participants": 20,
40+
"participants": ["lucy@mergington.edu", "ava@mergington.edu"]
41+
},
42+
"Music Ensemble": {
43+
"description": "Learn and perform music with the school ensemble",
44+
"schedule": "Fridays, 4:00 PM - 5:30 PM",
45+
"max_participants": 18,
46+
"participants": ["noah@mergington.edu"]
47+
},
48+
"Debate Team": {
49+
"description": "Develop critical thinking and public speaking skills",
50+
"schedule": "Mondays and Thursdays, 3:30 PM - 4:30 PM",
51+
"max_participants": 16,
52+
"participants": ["grace@mergington.edu", "thomas@mergington.edu"]
53+
},
54+
"Math Club": {
55+
"description": "Explore advanced mathematics and solve challenging problems",
56+
"schedule": "Tuesdays, 4:00 PM - 5:00 PM",
57+
"max_participants": 14,
58+
"participants": ["benjamin@mergington.edu"]
59+
},
2460
"Chess Club": {
2561
"description": "Learn strategies and compete in chess tournaments",
2662
"schedule": "Fridays, 3:30 PM - 5:00 PM",
@@ -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 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)