|
21 | 21 |
|
22 | 22 | # In-memory activity database |
23 | 23 | 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 | + }, |
24 | 60 | "Chess Club": { |
25 | 61 | "description": "Learn strategies and compete in chess tournaments", |
26 | 62 | "schedule": "Fridays, 3:30 PM - 5:00 PM", |
@@ -62,6 +98,10 @@ def signup_for_activity(activity_name: str, email: str): |
62 | 98 | # Get the specific activity |
63 | 99 | activity = activities[activity_name] |
64 | 100 |
|
| 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 | + |
65 | 105 | # Add student |
66 | 106 | activity["participants"].append(email) |
67 | 107 | return {"message": f"Signed up {email} for {activity_name}"} |
0 commit comments