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 @@ -38,6 +38,42 @@
"schedule": "Mondays, Wednesdays, Fridays, 2:00 PM - 3:00 PM",
"max_participants": 30,
"participants": ["[email protected]", "[email protected]"]
},
"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": ["[email protected]", "[email protected]"]
},
"Basketball Team": {
"description": "Practice and compete in basketball games",
"schedule": "Wednesdays and Fridays, 3:30 PM - 5:00 PM",
"max_participants": 15,
"participants": ["[email protected]", "[email protected]"]
},
"Art Club": {
"description": "Explore various art techniques and create projects",
"schedule": "Thursdays, 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": "Mondays and Wednesdays, 4:00 PM - 5:30 PM",
"max_participants": 20,
"participants": ["[email protected]", "[email protected]"]
},
"Math Club": {
"description": "Solve challenging math problems and compete in math contests",
"schedule": "Tuesdays, 3:30 PM - 4:30 PM",
"max_participants": 10,
"participants": ["[email protected]", "[email protected]"]
},
"Debate Team": {
"description": "Develop public speaking and argumentation skills",
"schedule": "Fridays, 4:00 PM - 5:30 PM",
"max_participants": 12,
"participants": ["[email protected]", "[email protected]"]
}
}

Expand All @@ -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}"}
Comment on lines +101 to 107
Copy link

Copilot AI May 10, 2025

Choose a reason for hiding this comment

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

Consider normalizing email addresses (e.g., converting them to lowercase) before checking for duplicates to ensure consistency.

Suggested change
# 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}"}
# Normalize email to lowercase
normalized_email = email.lower()
# Validate student is not already signed up
if normalized_email in activity["participants"]:
raise HTTPException(status_code=400, detail="Already signed up for this activity")
# Add student
activity["participants"].append(normalized_email)
return {"message": f"Signed up {normalized_email} for {activity_name}"}

Copilot uses AI. Check for mistakes.
6 changes: 6 additions & 0 deletions src/static/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ document.addEventListener("DOMContentLoaded", () => {
<p>${details.description}</p>
<p><strong>Schedule:</strong> ${details.schedule}</p>
<p><strong>Availability:</strong> ${spotsLeft} spots left</p>
<div class="participants">
<strong>Participants:</strong>
<ul>
${details.participants.map(participant => `<li>${participant}</li>`).join("")}
</ul>
</div>
`;

activitiesList.appendChild(activityCard);
Expand Down
25 changes: 25 additions & 0 deletions src/static/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -142,3 +142,28 @@ footer {
padding: 20px;
color: #666;
}

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

.participants strong {
display: block;
margin-bottom: 5px;
color: #0056b3;
}

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

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