From 60c2586b1a7a27936fe203cc4de51dc21ff71d50 Mon Sep 17 00:00:00 2001 From: wtobis-splunk Date: Tue, 24 Jun 2025 17:27:52 +0000 Subject: [PATCH 1/2] Add extracurricular activities and signup validation to the API --- src/app.py | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/src/app.py b/src/app.py index 4ebb1d9..c5e605e 100644 --- a/src/app.py +++ b/src/app.py @@ -38,6 +38,45 @@ "schedule": "Mondays, Wednesdays, Fridays, 2:00 PM - 3:00 PM", "max_participants": 30, "participants": ["john@mergington.edu", "olivia@mergington.edu"] + }, + # Sports related activities + "Soccer Team": { + "description": "Join the school soccer team and compete in local leagues", + "schedule": "Tuesdays and Thursdays, 4:00 PM - 5:30 PM", + "max_participants": 18, + "participants": ["lucas@mergington.edu", "mia@mergington.edu"] + }, + "Basketball Club": { + "description": "Practice basketball skills and play friendly matches", + "schedule": "Wednesdays, 3:30 PM - 5:00 PM", + "max_participants": 15, + "participants": ["liam@mergington.edu", "ava@mergington.edu"] + }, + # Artistic activities + "Art Club": { + "description": "Explore painting, drawing, and other visual arts", + "schedule": "Mondays, 3:30 PM - 5:00 PM", + "max_participants": 16, + "participants": ["ella@mergington.edu", "noah@mergington.edu"] + }, + "Drama Society": { + "description": "Participate in theater productions and acting workshops", + "schedule": "Fridays, 4:00 PM - 6:00 PM", + "max_participants": 20, + "participants": ["amelia@mergington.edu", "jack@mergington.edu"] + }, + # Intellectual activities + "Math Olympiad": { + "description": "Prepare for math competitions and solve challenging problems", + "schedule": "Thursdays, 3:30 PM - 5:00 PM", + "max_participants": 10, + "participants": ["ethan@mergington.edu", "grace@mergington.edu"] + }, + "Science Club": { + "description": "Conduct experiments and explore scientific concepts", + "schedule": "Wednesdays, 4:00 PM - 5:30 PM", + "max_participants": 14, + "participants": ["benjamin@mergington.edu", "chloe@mergington.edu"] } } @@ -62,6 +101,10 @@ def signup_for_activity(activity_name: str, email: str): # Get the specific activity activity = activities[activity_name] + # Validate student is not already signed up + 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 d80e1fd21f355cd9e19eac47a1ab0d991c85eb6d Mon Sep 17 00:00:00 2001 From: wtobis-splunk Date: Tue, 24 Jun 2025 17:37:23 +0000 Subject: [PATCH 2/2] Add participants section to activity cards and style updates --- src/static/app.js | 6 ++++++ src/static/styles.css | 23 +++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/src/static/app.js b/src/static/app.js index dcc1e38..01df780 100644 --- a/src/static/app.js +++ b/src/static/app.js @@ -25,6 +25,12 @@ document.addEventListener("DOMContentLoaded", () => {

${details.description}

Schedule: ${details.schedule}

Availability: ${spotsLeft} spots left

+
+ Participants: +
    + ${details.participants.length > 0 ? details.participants.map(p => `
  • ${p}
  • `).join("") : '
  • No participants yet
  • '} +
+
`; activitiesList.appendChild(activityCard); diff --git a/src/static/styles.css b/src/static/styles.css index a533b32..adfd8cf 100644 --- a/src/static/styles.css +++ b/src/static/styles.css @@ -142,3 +142,26 @@ footer { padding: 20px; color: #666; } + +.participants-section { + margin-top: 10px; + padding: 10px; + background-color: #eef3fb; + border-radius: 4px; +} + +.participants-section strong { + color: #1a237e; +} + +.participants-list { + margin: 8px 0 0 18px; + padding: 0; + list-style-type: disc; + color: #333; + font-size: 15px; +} + +.participants-list li { + margin-bottom: 3px; +}