Skip to content

Commit e0d69d7

Browse files
Merge pull request #2 from andrechalella/accelerate-with-copilot
Accelerate with copilot
2 parents 451b235 + d119399 commit e0d69d7

File tree

3 files changed

+111
-12
lines changed

3 files changed

+111
-12
lines changed

src/app.py

Lines changed: 43 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 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": 22,
47+
"participants": ["[email protected]", "[email protected]"]
48+
},
49+
"Basketball Club": {
50+
"description": "Practice basketball and participate in tournaments",
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 Workshop": {
57+
"description": "Explore painting, drawing, and sculpture techniques",
58+
"schedule": "Mondays, 4:00 PM - 5:30 PM",
59+
"max_participants": 18,
60+
"participants": ["[email protected]", "[email protected]"]
61+
},
62+
"Drama Club": {
63+
"description": "Act, direct, and produce school plays and performances",
64+
"schedule": "Fridays, 3:30 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": "Thursdays, 3:30 PM - 5:00 PM",
72+
"max_participants": 16,
73+
"participants": ["[email protected]", "[email protected]"]
74+
},
75+
"Debate Team": {
76+
"description": "Develop public speaking and argumentation skills",
77+
"schedule": "Wednesdays, 4:00 PM - 5:30 PM",
78+
"max_participants": 14,
79+
"participants": ["[email protected]", "[email protected]"]
4180
}
4281
}
4382

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

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

src/static/app.js

Lines changed: 41 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,7 @@ document.addEventListener("DOMContentLoaded", () => {
1515

1616
// Populate activities list
1717
Object.entries(activities).forEach(([name, details]) => {
18-
const activityCard = document.createElement("div");
19-
activityCard.className = "activity-card";
20-
21-
const spotsLeft = details.max_participants - details.participants.length;
22-
23-
activityCard.innerHTML = `
24-
<h4>${name}</h4>
25-
<p>${details.description}</p>
26-
<p><strong>Schedule:</strong> ${details.schedule}</p>
27-
<p><strong>Availability:</strong> ${spotsLeft} spots left</p>
28-
`;
29-
18+
const activityCard = renderActivityCard(name, details);
3019
activitiesList.appendChild(activityCard);
3120

3221
// Add option to select dropdown
@@ -41,6 +30,46 @@ document.addEventListener("DOMContentLoaded", () => {
4130
}
4231
}
4332

33+
// Render activity card
34+
function renderActivityCard(name, details) {
35+
const card = document.createElement("div");
36+
card.className = "activity-card";
37+
38+
const spotsLeft = details.max_participants - details.participants.length;
39+
40+
card.innerHTML = `
41+
<h4>${name}</h4>
42+
<p>${details.description}</p>
43+
<p><strong>Schedule:</strong> ${details.schedule}</p>
44+
<p><strong>Availability:</strong> ${spotsLeft} spots left</p>
45+
`;
46+
47+
// Participants section
48+
const participantsSection = document.createElement("div");
49+
participantsSection.className = "participants-section";
50+
const participantsTitle = document.createElement("h4");
51+
participantsTitle.textContent = "Participants";
52+
participantsSection.appendChild(participantsTitle);
53+
const participantsList = document.createElement("ul");
54+
participantsList.className = "participants-list";
55+
if (details.participants && details.participants.length > 0) {
56+
details.participants.forEach((participant) => {
57+
const li = document.createElement("li");
58+
li.textContent = participant;
59+
participantsList.appendChild(li);
60+
});
61+
} else {
62+
const li = document.createElement("li");
63+
li.textContent = "No participants yet.";
64+
li.className = "no-participants";
65+
participantsList.appendChild(li);
66+
}
67+
participantsSection.appendChild(participantsList);
68+
card.appendChild(participantsSection);
69+
70+
return card;
71+
}
72+
4473
// Handle form submission
4574
signupForm.addEventListener("submit", async (event) => {
4675
event.preventDefault();

src/static/styles.css

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,3 +142,30 @@ footer {
142142
padding: 20px;
143143
color: #666;
144144
}
145+
146+
.participants-section {
147+
background: #f8f9fa;
148+
border-radius: 8px;
149+
margin-top: 1em;
150+
padding: 1em;
151+
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
152+
}
153+
154+
.participants-section h4 {
155+
margin: 0 0 0.5em 0;
156+
font-size: 1.1em;
157+
color: #333;
158+
letter-spacing: 0.5px;
159+
}
160+
161+
.participants-list {
162+
list-style: disc inside;
163+
margin: 0;
164+
padding-left: 1em;
165+
color: #444;
166+
}
167+
168+
.participants-list li.no-participants {
169+
color: #aaa;
170+
font-style: italic;
171+
}

0 commit comments

Comments
 (0)