From f698725ed0466f9d95130df65a4b24a2aa7e02c1 Mon Sep 17 00:00:00 2001 From: James Webster Date: Mon, 9 Jun 2025 14:25:06 -0400 Subject: [PATCH 1/2] Add extracurricular activities and signup validation to API --- src/app.py | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/src/app.py b/src/app.py index 4ebb1d9..a2f4d97 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"] + }, + "Basketball Team": { + "description": "Competitive basketball training and games", + "schedule": "Tuesdays and Thursdays, 4:00 PM - 6:00 PM", + "max_participants": 15, + "participants": [] + }, + "Swimming Club": { + "description": "Swimming training and competitions", + "schedule": "Mondays and Wednesdays, 3:30 PM - 5:00 PM", + "max_participants": 20, + "participants": [] + }, + "Art Studio": { + "description": "Express creativity through various art mediums", + "schedule": "Wednesdays, 3:30 PM - 5:30 PM", + "max_participants": 15, + "participants": [] + }, + "Drama Club": { + "description": "Theater arts and performance training", + "schedule": "Tuesdays and Thursdays, 3:30 PM - 5:00 PM", + "max_participants": 25, + "participants": [] + }, + "Debate Team": { + "description": "Learn argumentation and public speaking skills", + "schedule": "Mondays, 4:00 PM - 5:30 PM", + "max_participants": 16, + "participants": [] + }, + "Science Club": { + "description": "Hands-on experiments and scientific exploration", + "schedule": "Fridays, 3:30 PM - 5:00 PM", + "max_participants": 20, + "participants": [] } } @@ -62,6 +98,10 @@ def signup_for_activity(activity_name: str, email: str): # Get the specific activity activity = activities[activity_name] + #Validate student does not already exist + if email in activity["participants"]: + raise HTTPException(status_code=400, detail="Student already signed up") + # Add student activity["participants"].append(email) return {"message": f"Signed up {email} for {activity_name}"} From 5230449938399bb084370a626286025f3609efd6 Mon Sep 17 00:00:00 2001 From: James Webster Date: Mon, 9 Jun 2025 14:34:13 -0400 Subject: [PATCH 2/2] Add participants section to activity cards and style updates --- src/static/app.js | 9 +++++++++ src/static/styles.css | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/src/static/app.js b/src/static/app.js index dcc1e38..8db3d7b 100644 --- a/src/static/app.js +++ b/src/static/app.js @@ -25,6 +25,15 @@ document.addEventListener("DOMContentLoaded", () => {

${details.description}

Schedule: ${details.schedule}

Availability: ${spotsLeft} spots left

+
+
Current Participants:
+ ${details.participants.length > 0 + ? `
    + ${details.participants.map(email => `
  • ${email}
  • `).join('')} +
` + : '

No participants yet

' + } +
`; activitiesList.appendChild(activityCard); diff --git a/src/static/styles.css b/src/static/styles.css index a533b32..d5031d3 100644 --- a/src/static/styles.css +++ b/src/static/styles.css @@ -74,6 +74,38 @@ section h3 { margin-bottom: 8px; } +.participants-section { + margin-top: 12px; + padding-top: 12px; + border-top: 1px solid #ddd; +} + +.participants-section h5 { + color: #555; + font-size: 0.9em; + margin-bottom: 8px; +} + +.participants-list { + list-style-type: none; + margin-left: 10px; +} + +.participants-list li { + color: #666; + font-size: 0.85em; + padding: 2px 0; + position: relative; + padding-left: 15px; +} + +.participants-list li::before { + content: "•"; + position: absolute; + left: 0; + color: #1a237e; +} + .form-group { margin-bottom: 15px; }