From a1ab929b0d2d5c97efec8194e6e7c2fde5a8c10e Mon Sep 17 00:00:00 2001 From: Jasper Boom Date: Thu, 3 Apr 2025 13:56:29 +0000 Subject: [PATCH 1/3] Add new activities and participant validation to app.py --- src/app.py | 42 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/src/app.py b/src/app.py index fd0c462..575abf5 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": ["alex@mergington.edu", "james@mergington.edu"] + }, + "Basketball Team": { + "description": "Practice and play basketball with the school team", + "schedule": "Wednesdays and Fridays, 3:30 PM - 5:00 PM", + "max_participants": 15, + "participants": ["luke@mergington.edu", "mason@mergington.edu"] + }, + "Art Club": { + "description": "Explore your creativity through painting and drawing", + "schedule": "Mondays, 3:30 PM - 5:00 PM", + "max_participants": 15, + "participants": ["ava@mergington.edu", "mia@mergington.edu"] + }, + "Drama Club": { + "description": "Participate in plays and improve your acting skills", + "schedule": "Thursdays, 4:00 PM - 5:30 PM", + "max_participants": 20, + "participants": ["isabella@mergington.edu", "amelia@mergington.edu"] + }, + "Math Club": { + "description": "Solve challenging problems and prepare for math competitions", + "schedule": "Wednesdays, 3:30 PM - 4:30 PM", + "max_participants": 10, + "participants": ["ethan@mergington.edu", "logan@mergington.edu"] + }, + "Science Club": { + "description": "Conduct experiments and explore scientific concepts", + "schedule": "Fridays, 4:00 PM - 5:00 PM", + "max_participants": 12, + "participants": ["harper@mergington.edu", "ella@mergington.edu"] } } @@ -62,6 +98,10 @@ def signup_for_activity(activity_name: str, email: str): # Get the specificy activity activity = activities[activity_name] + # Validate student is not already signed up + if email in activity["participants"]: + raise HTTPException(status_code=400, detail="Already signed up for this activity") + # Add student activity["participants"].append(email) - return {"message": f"Signed up {email} for {activity_name}"} + return {"message": f"Signed up {email} for {activity_name}"} \ No newline at end of file From 7b83a75040569c89b6d1d29d1ddcc390dd025427 Mon Sep 17 00:00:00 2001 From: Jasper Boom Date: Thu, 3 Apr 2025 14:14:00 +0000 Subject: [PATCH 2/3] Display participants list in activity cards and style the list --- src/static/app.js | 6 ++++++ src/static/styles.css | 11 +++++++++++ 2 files changed, 17 insertions(+) diff --git a/src/static/app.js b/src/static/app.js index dcc1e38..d20d9c9 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.map(participant => `
  • ${participant}
  • `).join("")} +
+
`; activitiesList.appendChild(activityCard); diff --git a/src/static/styles.css b/src/static/styles.css index a533b32..b20bafa 100644 --- a/src/static/styles.css +++ b/src/static/styles.css @@ -74,6 +74,17 @@ section h3 { margin-bottom: 8px; } +.activity-card ul { + margin-top: 10px; + padding-left: 20px; + list-style-type: disc; + color: #555; +} + +.activity-card ul li { + margin-bottom: 5px; +} + .form-group { margin-bottom: 15px; } From ee69697324f7dac3cfe080f95323e664ab4b4a7e Mon Sep 17 00:00:00 2001 From: Jasper Boom Date: Thu, 3 Apr 2025 14:20:46 +0000 Subject: [PATCH 3/3] Add styling for participant information section --- src/static/styles.css | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/static/styles.css b/src/static/styles.css index b20bafa..68ed03c 100644 --- a/src/static/styles.css +++ b/src/static/styles.css @@ -153,3 +153,23 @@ footer { padding: 20px; color: #666; } + +.participant-info { + margin-top: 15px; + padding: 10px; + border: 1px solid #ddd; + border-radius: 5px; + background-color: #f1f8e9; + color: #33691e; + font-size: 14px; +} + +.participant-info ul { + margin-top: 10px; + padding-left: 20px; + list-style-type: circle; +} + +.participant-info ul li { + margin-bottom: 5px; +} \ No newline at end of file