Skip to content

Commit a7175b4

Browse files
Add extracurricular activities and signup validation to the API
1 parent 54b71c4 commit a7175b4

File tree

1 file changed

+42
-1
lines changed

1 file changed

+42
-1
lines changed

src/app.py

Lines changed: 42 additions & 1 deletion
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 leagues",
45+
"schedule": "Tuesdays and Thursdays, 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 matches",
51+
"schedule": "Wednesdays, 3:30 PM - 5:00 PM",
52+
"max_participants": 15,
53+
"participants": ["[email protected]", "[email protected]"]
54+
},
55+
# Artistic activities
56+
"Art Club": {
57+
"description": "Explore painting, drawing, and other visual arts",
58+
"schedule": "Mondays, 3:30 PM - 5:00 PM",
59+
"max_participants": 18,
60+
"participants": ["[email protected]", "[email protected]"]
61+
},
62+
"Drama Society": {
63+
"description": "Participate in theater productions and acting workshops",
64+
"schedule": "Fridays, 4:00 PM - 6:00 PM",
65+
"max_participants": 25,
66+
"participants": ["[email protected]", "[email protected]"]
67+
},
68+
# Intellectual activities
69+
"Math Olympiad": {
70+
"description": "Prepare for math competitions and solve challenging problems",
71+
"schedule": "Thursdays, 3:30 PM - 5:00 PM",
72+
"max_participants": 16,
73+
"participants": ["[email protected]", "[email protected]"]
74+
},
75+
"Science Club": {
76+
"description": "Conduct experiments and explore scientific concepts",
77+
"schedule": "Wednesdays, 4:00 PM - 5:30 PM",
78+
"max_participants": 20,
79+
"participants": ["[email protected]", "[email protected]"]
4180
}
4281
}
4382

@@ -61,7 +100,9 @@ def signup_for_activity(activity_name: str, email: str):
61100

62101
# Get the specificy activity
63102
activity = activities[activity_name]
64-
103+
# Validate student is not already signed up
104+
if email in activity["participants"]:
105+
raise HTTPException(status_code=400, detail="Already signed up for this activity")
65106
# Add student
66107
activity["participants"].append(email)
67108
return {"message": f"Signed up {email} for {activity_name}"}

0 commit comments

Comments
 (0)