From a9c554a9f800ceb5b683c9250cdff5b1407e13ad Mon Sep 17 00:00:00 2001 From: Luhfernanda <144925591+Luhfernanda@users.noreply.github.com> Date: Fri, 27 Jun 2025 14:28:54 +0000 Subject: [PATCH 1/2] =?UTF-8?q?Adiciona=20atividades=20extracurriculares?= =?UTF-8?q?=20e=20valida=C3=A7=C3=A3o=20de=20inscri=C3=A7=C3=A3o?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app.py | 61 ++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 52 insertions(+), 9 deletions(-) diff --git a/src/app.py b/src/app.py index 4ebb1d9..ae25058 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 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": ["charlotte@mergington.edu", "benjamin@mergington.edu"] + }, + "Science Club": { + "description": "Conduct experiments and explore scientific concepts", + "schedule": "Wednesdays, 4:00 PM - 5:30 PM", + "max_participants": 14, + "participants": ["henry@mergington.edu", "grace@mergington.edu"] } } @@ -54,14 +93,18 @@ def get_activities(): @app.post("/activities/{activity_name}/signup") def signup_for_activity(activity_name: str, email: str): - """Sign up a student for an activity""" - # Validate activity exists - if activity_name not in activities: - raise HTTPException(status_code=404, detail="Activity not found") + """Sign up a student for an activity""" + # Validate activity exists + if activity_name not in activities: + raise HTTPException(status_code=404, detail="Activity not found") + + # Get the activity + activity = activities[activity_name] - # 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 is already signed up") - # Add student - activity["participants"].append(email) - return {"message": f"Signed up {email} for {activity_name}"} + # Add student + activity["participants"].append(email) + return {"message": f"Signed up {email} for {activity_name}"} From 4af7c915131aa9faad44d1399c379a1647902969 Mon Sep 17 00:00:00 2001 From: Luhfernanda <144925591+Luhfernanda@users.noreply.github.com> Date: Fri, 27 Jun 2025 14:38:46 +0000 Subject: [PATCH 2/2] =?UTF-8?q?Adiciona=20se=C3=A7=C3=A3o=20de=20participa?= =?UTF-8?q?ntes=20e=20estilos=20correspondentes=20nas=20atividades?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/static/app.js | 21 +++++++++++++++++++++ src/static/styles.css | 25 +++++++++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/src/static/app.js b/src/static/app.js index dcc1e38..43421e4 100644 --- a/src/static/app.js +++ b/src/static/app.js @@ -20,11 +20,32 @@ document.addEventListener("DOMContentLoaded", () => { const spotsLeft = details.max_participants - details.participants.length; + // Lista de participantes formatada + let participantsHTML = ""; + if (details.participants.length > 0) { + participantsHTML = ` +
+ Participantes: + +
+ `; + } else { + participantsHTML = ` +
+ Participantes: + Nenhum inscrito ainda. +
+ `; + } + activityCard.innerHTML = `

${name}

${details.description}

Schedule: ${details.schedule}

Availability: ${spotsLeft} spots left

+ ${participantsHTML} `; activitiesList.appendChild(activityCard); diff --git a/src/static/styles.css b/src/static/styles.css index a533b32..6ee2fbd 100644 --- a/src/static/styles.css +++ b/src/static/styles.css @@ -142,3 +142,28 @@ footer { padding: 20px; color: #666; } + +.participants-section { + margin-top: 12px; + padding-top: 10px; + border-top: 1px solid #e0e0e0; +} + +.participants-section strong { + color: #3949ab; + font-size: 15px; +} + +.participants-list { + margin: 8px 0 0 18px; + padding-left: 0; + list-style-type: disc; + color: #333; + font-size: 15px; +} + +.no-participants { + color: #888; + font-style: italic; + margin-left: 5px; +}