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
44 changes: 44 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 tournaments",
"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 your own masterpieces",
"schedule": "Thursdays, 3:30 PM - 5:00 PM",
"max_participants": 15,
"participants": ["[email protected]", "[email protected]"]
},
"Drama Club": {
"description": "Participate in plays and improve your 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 prepare for competitions",
"schedule": "Tuesdays, 3:30 PM - 4:30 PM",
"max_participants": 10,
"participants": ["[email protected]", "[email protected]"]
},
"Science Club": {
"description": "Conduct experiments and explore scientific concepts",
"schedule": "Fridays, 3:30 PM - 5:00 PM",
"max_participants": 12,
"participants": ["[email protected]", "[email protected]"]
}
}

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

# validate if the student is already signed up
if email in activity["participants"]:
raise HTTPException(status_code=400, detail="Already signed up for this activity")

# validate if the activity is full
if len(activity["participants"]) >= activity["max_participants"]:
raise HTTPException(status_code=400, detail="Activity is full")

# 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 @@ -25,6 +25,14 @@ 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.length > 0
? details.participants.map(participant => `<li>${participant}</li>`).join("")
: "<li>No participants yet</li>"}
</ul>
</div>
`;

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

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

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

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