diff --git a/src/app.py b/src/app.py index fd0c462..a97e835 100644 --- a/src/app.py +++ b/src/app.py @@ -38,6 +38,42 @@ "schedule": "Mondays, Wednesdays, Fridays, 2:00 PM - 3:00 PM", "max_participants": 30, "participants": ["john@mergington.edu", "olivia@mergington.edu"] + }, + "Soccer Team": { + "description": "Join the school soccer team and compete in matches", + "schedule": "Tuesdays and Thursdays, 4:00 PM - 5:30 PM", + "max_participants": 22, + "participants": ["liam@mergington.edu", "noah@mergington.edu"] + }, + "Basketball Team": { + "description": "Practice and compete in basketball tournaments", + "schedule": "Wednesdays and Fridays, 3:30 PM - 5:00 PM", + "max_participants": 15, + "participants": ["ava@mergington.edu", "mia@mergington.edu"] + }, + "Art Club": { + "description": "Explore various art techniques and create your own masterpieces", + "schedule": "Thursdays, 3:30 PM - 5:00 PM", + "max_participants": 15, + "participants": ["amelia@mergington.edu", "isabella@mergington.edu"] + }, + "Drama Club": { + "description": "Participate in plays and improve your acting skills", + "schedule": "Mondays and Wednesdays, 4:00 PM - 5:30 PM", + "max_participants": 20, + "participants": ["elijah@mergington.edu", "lucas@mergington.edu"] + }, + "Math Club": { + "description": "Solve challenging math problems and prepare for competitions", + "schedule": "Tuesdays, 3:30 PM - 4:30 PM", + "max_participants": 10, + "participants": ["charlotte@mergington.edu", "harper@mergington.edu"] + }, + "Science Club": { + "description": "Conduct experiments and explore scientific concepts", + "schedule": "Fridays, 3:30 PM - 5:00 PM", + "max_participants": 12, + "participants": ["henry@mergington.edu", "jack@mergington.edu"] } } @@ -62,6 +98,14 @@ def signup_for_activity(activity_name: str, email: str): # Get the specificy activity activity = activities[activity_name] + # validate if the student is already signed up + if email in activity["participants"]: + raise HTTPException(status_code=400, detail="Already signed up for this activity") + + # validate if the activity is full + if len(activity["participants"]) >= activity["max_participants"]: + raise HTTPException(status_code=400, detail="Activity is full") + # Add student activity["participants"].append(email) return {"message": f"Signed up {email} for {activity_name}"} diff --git a/src/static/app.js b/src/static/app.js index dcc1e38..0a8e58f 100644 --- a/src/static/app.js +++ b/src/static/app.js @@ -25,6 +25,14 @@ document.addEventListener("DOMContentLoaded", () => {
${details.description}
Schedule: ${details.schedule}
Availability: ${spotsLeft} spots left
+