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
40 changes: 40 additions & 0 deletions src/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,42 @@

# In-memory activity database
Copy link

Copilot AI Apr 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Consider adding a comment block to summarize the new activities in the in-memory database for improved readability and maintenance.

Suggested change
# In-memory activity database
# In-memory activity database
# This dictionary stores information about extracurricular activities available at Mergington High School.
# Each activity is represented as a key-value pair, where the key is the activity name (string) and the value
# is a dictionary containing:
# - "description": A brief description of the activity.
# - "schedule": The days and times the activity takes place.
# - "max_participants": The maximum number of participants allowed.
# - "participants": A list of email addresses of current participants.

Copilot uses AI. Check for mistakes.
activities = {
"Soccer Team": {
"description": "Join the soccer team and compete in matches",
"schedule": "Tuesdays and Thursdays, 4:00 PM - 5:30 PM",
"max_participants": 22,
"participants": ["[email protected]", "[email protected]"]
},
"Basketball Team": {
"description": "Practice basketball skills and participate in tournaments",
"schedule": "Mondays and Wednesdays, 4:00 PM - 5:30 PM",
"max_participants": 15,
"participants": ["[email protected]", "[email protected]"]
},
"Art Club": {
"description": "Explore various art techniques and create your own masterpieces",
"schedule": "Wednesdays, 3:30 PM - 5:00 PM",
"max_participants": 15,
"participants": ["[email protected]", "[email protected]"]
},
"Drama Club": {
"description": "Participate in plays and improve acting skills",
"schedule": "Fridays, 3:30 PM - 5:30 PM",
"max_participants": 20,
"participants": ["[email protected]", "[email protected]"]
},
"Math Club": {
"description": "Solve challenging math problems and prepare for competitions",
"schedule": "Thursdays, 3:30 PM - 4:30 PM",
"max_participants": 10,
"participants": ["[email protected]", "[email protected]"]
},
"Science Club": {
"description": "Conduct experiments and explore scientific concepts",
"schedule": "Tuesdays, 3:30 PM - 4:30 PM",
"max_participants": 12,
"participants": ["[email protected]", "[email protected]"]
},
"Chess Club": {
"description": "Learn strategies and compete in chess tournaments",
"schedule": "Fridays, 3:30 PM - 5:00 PM",
Expand Down Expand Up @@ -62,6 +98,10 @@ def signup_for_activity(activity_name: str, email: str):
# Get the specificy activity
activity = activities[activity_name]

# Verify student isn't 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}"}
8 changes: 8 additions & 0 deletions src/static/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,19 @@ document.addEventListener("DOMContentLoaded", () => {

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

const participantsList = details.participants.length
? `<ul>${details.participants.map(participant => `<li>${participant}</li>`).join("")}</ul>`
: "<p>No participants yet.</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>
<div class="participants">
<h5>Participants:</h5>
${participantsList}
</div>
`;

activitiesList.appendChild(activityCard);
Expand Down
23 changes: 23 additions & 0 deletions src/static/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,29 @@ button:hover {
display: none;
}

.participants {
margin-top: 15px;
padding: 10px;
border-top: 1px solid #ddd;
background-color: #f1f8e9;
border-radius: 5px;
}

.participants h5 {
margin-bottom: 10px;
color: #2e7d32;
}

.participants ul {
list-style-type: disc;
padding-left: 20px;
}

.participants li {
margin-bottom: 5px;
color: #333;
}

footer {
text-align: center;
margin-top: 30px;
Expand Down