Skip to content

Accelerate with copilot#2

Merged
pmca31 merged 21 commits intomainfrom
accelerate-with-copilot
Feb 10, 2026
Merged

Accelerate with copilot#2
pmca31 merged 21 commits intomainfrom
accelerate-with-copilot

Conversation

@pmca31
Copy link
Owner

@pmca31 pmca31 commented Feb 10, 2026

This pull request introduces several new features and improvements to the High School Management System, focusing on activity management, user experience enhancements, and test coverage. The most significant changes include the addition of an activity unregistration feature, improved frontend participant management, and expanded backend activity data. Automated tests have also been added to ensure correct API behavior.

Backend enhancements:

  • Added a new /activities/{activity_name}/unregister POST endpoint in src/app.py to allow participants to be removed from activities, with appropriate error handling for missing activities or participants.
  • Expanded the in-memory activities database in src/app.py to include more activities such as Basketball Team, Soccer Club, Drama Club, Art Workshop, Math Olympiad, and Science Club, each with their own details.
  • Updated the signup logic in src/app.py to prevent duplicate signups by checking if a student is already registered before adding them.

Frontend improvements:

  • Updated src/static/app.js to display a list of participants for each activity, including a delete icon for each participant that allows removal via the new unregistration endpoint. The participant list refreshes automatically after changes. [1] [2]
  • Enhanced the UI in src/static/styles.css to style the participants section, making it visually distinct and user-friendly.

Testing:

  • Added comprehensive API tests in tests/test_app.py to cover activity retrieval, signup, unregistration, duplicate signup prevention, non-existent activities, participant removal, activity capacity limits, and static file serving.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request adds activity unregistration functionality, enhances the frontend with participant management UI, expands the activity database, and adds comprehensive API testing to the High School Management System. However, the PR contains several critical bugs that prevent it from functioning correctly, including structural issues in tests, improper code placement, duplicate imports, and security vulnerabilities.

Changes:

  • Added /activities/{activity_name}/unregister POST endpoint to remove participants from activities
  • Enhanced frontend JavaScript to display participant lists with delete functionality for each participant
  • Expanded activity database with six new activities (Basketball Team, Soccer Club, Drama Club, Art Workshop, Math Olympiad, Science Club)
  • Added duplicate signup prevention and comprehensive API tests

Reviewed changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 19 comments.

Show a summary per file
File Description
tests/test_app.py New test file with API tests, but contains critical structural issues with nested function definitions
src/static/styles.css Added CSS styling for the participants section UI
src/static/app.js Enhanced to display participants with delete icons and refresh activities after changes, but has XSS vulnerabilities
src/app.py Added unregister endpoint, expanded activities database, duplicate signup prevention, but has import issues and missing capacity validation
requirements.txt Added pytest, httpx, and pytest-cov for testing infrastructure

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 32 to 36
(email) =>
`<div class="participant-item">
<span class="participant-email">${email}</span>
<span class="delete-icon" title="Remove participant" data-activity="${name}" data-email="${email}">&#128465;</span>
</div>`
Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

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

XSS vulnerability: The activity name and email addresses are directly interpolated into HTML without proper escaping. If user-provided data (like email addresses) contains HTML/JavaScript, it will be executed in the browser. Use textContent for user-provided data or properly escape HTML entities before inserting into innerHTML.

Copilot uses AI. Check for mistakes.
src/app.py Outdated
app.mount("/static", StaticFiles(directory=os.path.join(Path(__file__).parent, "static")), name="static")
# Unregister endpoint
@app.post("/activities/{activity_name}/unregister")
async def unregister_from_activity(activity_name: str, email: str):
Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

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

Missing email validation: The unregister endpoint accepts any string as an email parameter without validation. This should validate email format for consistency with the signup endpoint.

Copilot uses AI. Check for mistakes.
Comment on lines 36 to 46
def test_max_participants_limit():
activity = "Art Workshop"
emails = [f"user{i}@example.com" for i in range(1, 22)]
# Fill up the activity
for email in emails[:20]:
resp = client.post(f"/activities/{activity}/signup?email={email}")
assert resp.status_code == 200 or resp.status_code == 400
# Try to add one more
resp = client.post(f"/activities/{activity}/signup?email={emails[20]}")
assert resp.status_code == 400
assert resp.json()["detail"] == "Activity is full"
Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

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

Test isolation issue: The test_max_participants_limit test fills up "Art Workshop" with 20 participants but doesn't clean up afterwards. This could cause other tests to fail if they depend on Art Workshop having available slots. Tests should either use unique test data, clean up after themselves, or use fixtures to reset state.

Copilot uses AI. Check for mistakes.
Copy link
Contributor

Copilot AI commented Feb 10, 2026

@pmca31 I've opened a new pull request, #3, to work on those changes. Once the pull request is ready, I'll request review from you.

Copy link
Contributor

Copilot AI commented Feb 10, 2026

@pmca31 I've opened a new pull request, #4, to work on those changes. Once the pull request is ready, I'll request review from you.

pmca31 and others added 2 commits February 10, 2026 16:58
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Contributor

Copilot AI commented Feb 10, 2026

@pmca31 I've opened a new pull request, #5, to work on those changes. Once the pull request is ready, I'll request review from you.

pmca31 and others added 11 commits February 10, 2026 16:58
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: pmca31 <6774003+pmca31@users.noreply.github.com>
Co-authored-by: pmca31 <6774003+pmca31@users.noreply.github.com>
Co-authored-by: pmca31 <6774003+pmca31@users.noreply.github.com>
Co-authored-by: pmca31 <6774003+pmca31@users.noreply.github.com>
Co-authored-by: pmca31 <6774003+pmca31@users.noreply.github.com>
Co-authored-by: pmca31 <6774003+pmca31@users.noreply.github.com>
Fix Python execution order: move unregister endpoint after activities dict
Fix XSS vulnerability in activity card rendering
Add email validation for empty and whitespace-only values
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 5 changed files in this pull request and generated 4 comments.

Comments suppressed due to low confidence (1)

src/app.py:16

  • Top of file has duplicate imports and a placeholder comment (# ...existing code...) plus unused imports (Request, JSONResponse) and an unused variable (current_dir). This adds noise and can confuse readers; remove duplicates/placeholders and keep only the imports actually used in this module.
from fastapi import FastAPI, HTTPException, Request
from fastapi.responses import JSONResponse
# ...existing code...
"""
High School Management System API

A super simple FastAPI application that allows students to view and sign up
for extracurricular activities at Mergington High School.
"""

from fastapi import FastAPI, HTTPException
from fastapi.staticfiles import StaticFiles
from fastapi.responses import RedirectResponse
import os
from pathlib import Path


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

.participants-list {
margin-top: 6px;
margin-left: 18px;
list-style-type: disc;
Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

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

.participants-list is styled with list-style-type: disc, but the JS creates it as a <div> containing <div> items, so list bullets won’t render. Use semantic <ul>/<li> in the markup (and update CSS selectors accordingly), or remove list-style-related CSS and implement bullets another way.

Suggested change
list-style-type: disc;

Copilot uses AI. Check for mistakes.
Comment on lines +58 to +62
const participantsList = document.createElement("div");
participantsList.className = "participants-list";

details.participants.forEach((email) => {
const participantItem = document.createElement("div");
Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

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

Participants markup uses <div class="participants-list"> / <div class="participant-item">, but the CSS suggests a list with bullets. Consider rendering participants as a <ul> with <li> items (or adjust CSS) so the UI matches the intended styling and improves semantics for assistive tech.

Suggested change
const participantsList = document.createElement("div");
participantsList.className = "participants-list";
details.participants.forEach((email) => {
const participantItem = document.createElement("div");
const participantsList = document.createElement("ul");
participantsList.className = "participants-list";
details.participants.forEach((email) => {
const participantItem = document.createElement("li");

Copilot uses AI. Check for mistakes.
Comment on lines 104 to 114
# Get the specific activity
activity = activities[activity_name]

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


# Add student
activity["participants"].append(email)
return {"message": f"Signed up {email} for {activity_name}"}
Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

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

signup_for_activity no longer enforces max_participants capacity before appending to participants. This makes it possible to overfill an activity and will break the expected 400 "Activity is full" behavior (see tests). Add a check comparing len(activity["participants"]) against activity["max_participants"] and raise HTTPException(400, "Activity is full") before appending.

Copilot uses AI. Check for mistakes.
Copy link
Contributor

Copilot AI commented Feb 10, 2026

@pmca31 I've opened a new pull request, #6, to work on those changes. Once the pull request is ready, I'll request review from you.

Copilot AI and others added 2 commits February 10, 2026 18:36
Co-authored-by: pmca31 <6774003+pmca31@users.noreply.github.com>
Remove async from unregister_from_activity
@pmca31 pmca31 merged commit fd897bb into main Feb 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants