Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions src/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 matches",
"schedule": "Wednesdays, 4:00 PM - 5:30 PM",
"max_participants": 22,
"participants": ["alex@mergington.edu", "lucas@mergington.edu"]
},
"Basketball Club": {
"description": "Practice basketball skills and play friendly games",
"schedule": "Mondays, 3:30 PM - 5:00 PM",
"max_participants": 15,
"participants": ["mia@mergington.edu", "noah@mergington.edu"]
},
# Artistic activities
"Art Workshop": {
"description": "Explore painting, drawing, and sculpture techniques",
"schedule": "Thursdays, 4:00 PM - 5:30 PM",
"max_participants": 18,
"participants": ["ava@mergington.edu", "liam@mergington.edu"]
},
"Drama Club": {
"description": "Act, direct, and produce school plays and performances",
"schedule": "Tuesdays, 3:30 PM - 5:00 PM",
"max_participants": 20,
"participants": ["ella@mergington.edu", "jack@mergington.edu"]
},
# Intellectual activities
"Debate Team": {
"description": "Develop public speaking and argumentation skills",
"schedule": "Fridays, 4:00 PM - 5:30 PM",
"max_participants": 16,
"participants": ["chloe@mergington.edu", "ethan@mergington.edu"]
},
"Math Club": {
"description": "Solve challenging math problems and prepare for competitions",
"schedule": "Wednesdays, 3:30 PM - 4:30 PM",
"max_participants": 14,
"participants": ["zoe@mergington.edu", "ben@mergington.edu"]
}
}

Expand All @@ -62,6 +101,10 @@ def signup_for_activity(activity_name: str, email: str):
# Get the specific activity
activity = activities[activity_name]

# Validate email is not already signed up
if email in activity["participants"]:
raise HTTPException(status_code=400, detail="Email already signed up for this activity")
Comment thread
hwulet marked this conversation as resolved.

# Add student
activity["participants"].append(email)
return {"message": f"Signed up {email} for {activity_name}"}
24 changes: 23 additions & 1 deletion src/static/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,35 @@ document.addEventListener("DOMContentLoaded", () => {

const spotsLeft = details.max_participants - details.participants.length;

// Create participants section safely
let participantsSection = document.createElement("div");
participantsSection.className = "participants-section";
const participantsHeader = document.createElement("h5");
participantsHeader.textContent = "Participants:";
participantsSection.appendChild(participantsHeader);
if (details.participants.length > 0) {
const ul = document.createElement("ul");
ul.className = "participants-list";
details.participants.forEach(email => {
const li = document.createElement("li");
li.textContent = email;
ul.appendChild(li);
});
participantsSection.appendChild(ul);
} else {
const p = document.createElement("p");
p.className = "no-participants";
p.textContent = "No participants yet";
participantsSection.appendChild(p);
}

activityCard.innerHTML = `
<h4>${name}</h4>
<p>${details.description}</p>
<p><strong>Schedule:</strong> ${details.schedule}</p>
<p><strong>Availability:</strong> ${spotsLeft} spots left</p>
`;

activityCard.appendChild(participantsSection);
activitiesList.appendChild(activityCard);

// Add option to select dropdown
Expand Down
41 changes: 41 additions & 0 deletions src/static/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,47 @@ section h3 {
margin-bottom: 8px;
}

.participants-section {
margin-top: 15px;
padding-top: 10px;
border-top: 1px solid #e0e0e0;
}

.participants-section h5 {
margin-bottom: 8px;
color: #1a237e;
font-size: 14px;
font-weight: bold;
}

.participants-list {
list-style: none;
padding: 0;
margin: 0;
}

.participants-list li {
padding: 3px 0;
padding-left: 15px;
position: relative;
font-size: 14px;
color: #555;
}

.participants-list li:before {
content: "•";
color: #1a237e;
font-weight: bold;
position: absolute;
left: 0;
}

.no-participants {
font-style: italic;
color: #888;
font-size: 14px;
}

.form-group {
margin-bottom: 15px;
}
Expand Down