Skip to content

Commit db3b71d

Browse files
authored
Merge pull request #2 from sunil-archt/accelerate-with-copilot
Add registration validation and more activities
2 parents 5c34150 + 4e71b67 commit db3b71d

File tree

3 files changed

+76
-0
lines changed

3 files changed

+76
-0
lines changed

src/app.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,45 @@
3838
"schedule": "Mondays, Wednesdays, Fridays, 2:00 PM - 3:00 PM",
3939
"max_participants": 30,
4040
"participants": ["[email protected]", "[email protected]"]
41+
},
42+
# Sports related activities
43+
"Soccer Team": {
44+
"description": "Join the school soccer team and compete in local leagues",
45+
"schedule": "Tuesdays and Thursdays, 4:00 PM - 5:30 PM",
46+
"max_participants": 18,
47+
"participants": ["[email protected]", "[email protected]"]
48+
},
49+
"Basketball Club": {
50+
"description": "Practice basketball skills and play friendly matches",
51+
"schedule": "Wednesdays, 3:30 PM - 5:00 PM",
52+
"max_participants": 15,
53+
"participants": ["[email protected]", "[email protected]"]
54+
},
55+
# Artistic activities
56+
"Art Club": {
57+
"description": "Explore painting, drawing, and other visual arts",
58+
"schedule": "Mondays, 3:30 PM - 5:00 PM",
59+
"max_participants": 16,
60+
"participants": ["[email protected]", "[email protected]"]
61+
},
62+
"Drama Society": {
63+
"description": "Participate in school plays and drama workshops",
64+
"schedule": "Thursdays, 4:00 PM - 5:30 PM",
65+
"max_participants": 20,
66+
"participants": ["[email protected]", "[email protected]"]
67+
},
68+
# Intellectual activities
69+
"Math Olympiad": {
70+
"description": "Prepare for math competitions and solve challenging problems",
71+
"schedule": "Fridays, 2:00 PM - 3:30 PM",
72+
"max_participants": 10,
73+
"participants": ["[email protected]", "[email protected]"]
74+
},
75+
"Science Club": {
76+
"description": "Conduct experiments and explore scientific concepts",
77+
"schedule": "Wednesdays, 4:00 PM - 5:00 PM",
78+
"max_participants": 14,
79+
"participants": ["[email protected]", "[email protected]"]
4180
}
4281
}
4382

@@ -62,6 +101,11 @@ def signup_for_activity(activity_name: str, email: str):
62101
# Get the specific activity
63102
activity = activities[activity_name]
64103

104+
# Check if student is already signed up
105+
if email in activity["participants"]:
106+
raise HTTPException(status_code=400, detail="Student is already signed up for this activity")
107+
108+
65109
# Add student
66110
activity["participants"].append(email)
67111
return {"message": f"Signed up {email} for {activity_name}"}

src/static/app.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,19 @@ document.addEventListener("DOMContentLoaded", () => {
2020

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

23+
const participantsList = details.participants.length > 0
24+
? `<ul class="participants-list">${details.participants.map(email => `<li>${email}</li>`).join('')}</ul>`
25+
: '<p class="no-participants">No participants yet</p>';
26+
2327
activityCard.innerHTML = `
2428
<h4>${name}</h4>
2529
<p>${details.description}</p>
2630
<p><strong>Schedule:</strong> ${details.schedule}</p>
2731
<p><strong>Availability:</strong> ${spotsLeft} spots left</p>
32+
<div class="participants-section">
33+
<p><strong>Participants:</strong></p>
34+
${participantsList}
35+
</div>
2836
`;
2937

3038
activitiesList.appendChild(activityCard);

src/static/styles.css

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,30 @@ section h3 {
7474
margin-bottom: 8px;
7575
}
7676

77+
.participants-section {
78+
margin-top: 15px;
79+
padding-top: 10px;
80+
border-top: 1px solid #e0e0e0;
81+
}
82+
83+
.participants-list {
84+
margin: 8px 0 0 20px;
85+
padding: 0;
86+
}
87+
88+
.participants-list li {
89+
margin-bottom: 4px;
90+
color: #666;
91+
font-size: 14px;
92+
}
93+
94+
.no-participants {
95+
margin: 8px 0 0 0 !important;
96+
color: #999;
97+
font-style: italic;
98+
font-size: 14px;
99+
}
100+
77101
.form-group {
78102
margin-bottom: 15px;
79103
}

0 commit comments

Comments
 (0)