Skip to content

Commit aaa4276

Browse files
committed
Add extracurricular activities and signup validation to the API
1 parent 2161692 commit aaa4276

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

src/app.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,45 @@
3838
"schedule": "Mondays, Wednesdays, Fridays, 2:00 PM - 3:00 PM",
3939
"max_participants": 30,
4040
"participants": ["[email protected]", "[email protected]"]
41+
},
42+
# Sports related activities
43+
"Soccer Team": {
44+
"description": "Join the school soccer team and compete in local matches",
45+
"schedule": "Wednesdays, 4:00 PM - 5:30 PM",
46+
"max_participants": 22,
47+
"participants": ["[email protected]", "[email protected]"]
48+
},
49+
"Basketball Club": {
50+
"description": "Practice basketball skills and play friendly games",
51+
"schedule": "Mondays, 3:30 PM - 5:00 PM",
52+
"max_participants": 15,
53+
"participants": ["[email protected]", "[email protected]"]
54+
},
55+
# Artistic activities
56+
"Art Workshop": {
57+
"description": "Explore painting, drawing, and sculpture techniques",
58+
"schedule": "Thursdays, 4:00 PM - 5:30 PM",
59+
"max_participants": 18,
60+
"participants": ["[email protected]", "[email protected]"]
61+
},
62+
"Drama Club": {
63+
"description": "Act in plays and learn stage performance skills",
64+
"schedule": "Tuesdays, 3:30 PM - 5:00 PM",
65+
"max_participants": 20,
66+
"participants": ["[email protected]", "[email protected]"]
67+
},
68+
# Intellectual activities
69+
"Mathletes": {
70+
"description": "Compete in math competitions and solve challenging problems",
71+
"schedule": "Fridays, 4:00 PM - 5:00 PM",
72+
"max_participants": 10,
73+
"participants": ["[email protected]", "[email protected]"]
74+
},
75+
"Science Club": {
76+
"description": "Conduct experiments and explore scientific concepts",
77+
"schedule": "Wednesdays, 3:30 PM - 5:00 PM",
78+
"max_participants": 16,
79+
"participants": ["[email protected]", "[email protected]"]
4180
}
4281
}
4382

@@ -62,6 +101,10 @@ def signup_for_activity(activity_name: str, email: str):
62101
# Get the specific activity
63102
activity = activities[activity_name]
64103

104+
# Validate student is not already signed up
105+
if email in activity["participants"]:
106+
raise HTTPException(status_code=400, detail="Student already signed up")
107+
65108
# Add student
66109
activity["participants"].append(email)
67110
return {"message": f"Signed up {email} for {activity_name}"}

0 commit comments

Comments
 (0)