Skip to content

Improve student activity registration system#2

Merged
dotanp merged 3 commits into
mainfrom
accelerate-with-copilot
Jun 26, 2026
Merged

Improve student activity registration system#2
dotanp merged 3 commits into
mainfrom
accelerate-with-copilot

Conversation

@dotanp

@dotanp dotanp commented Jun 26, 2026

Copy link
Copy Markdown
Owner

This pull request introduces a comprehensive set of improvements to the Mergington High School Activities web app, focusing on participant management, UI enhancements, and test coverage. The main updates include support for viewing and removing participants from activities, improved frontend display and interaction, and a new test suite to ensure reliability.

Backend Enhancements:

  • Added a DELETE endpoint (/activities/{activity_name}/participants/{email}) to allow unregistering students from activities, with validation to prevent duplicate signups and handle errors for unknown activities or participants.
  • Expanded the set of available activities and their participant lists in src/app.py.

Frontend Improvements:

  • Updated the activities list UI to display current participants for each activity, including a delete (unregister) button for each participant. Input is safely escaped to prevent XSS attacks.
  • Implemented frontend logic to handle participant removal via the new backend endpoint, with success/error messaging and UI refresh. [1] [2]
  • Enhanced the visual styling for the participants section and participant management buttons in styles.css. [1] [2]

Testing and Configuration:

  • Added a robust test suite for all core API endpoints, including participant signup, duplicate handling, and unregistering logic, with fixtures to reset state between tests. [1] [2]
  • Updated pytest.ini to ensure tests are discovered and run from the correct paths.

Other:

  • Updated resource links in index.html to ensure cache busting for the latest JS and CSS changes. [1] [2]

@dotanp dotanp requested a review from Copilot June 26, 2026 16:41
@dotanp dotanp merged commit 89e079e into main Jun 26, 2026
4 checks passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR enhances the Mergington High School Activities app by adding participant management (including unregistering), updating the frontend to display/manage participant lists, and introducing an initial API-focused test suite to keep behavior stable.

Changes:

  • Added a backend DELETE endpoint to unregister a participant from an activity, plus expanded the in-memory activities dataset.
  • Updated the frontend to render participant lists per activity and support participant removal with UI feedback/refresh.
  • Added pytest configuration and tests covering core endpoints (root redirect, list activities, signup, duplicate handling, unregister).

Reviewed changes

Copilot reviewed 7 out of 9 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tests/test_app.py Adds API tests for listing activities, signup, duplicate handling, and unregister behavior.
tests/conftest.py Adds pytest fixtures to isolate/reset the in-memory activities state and provide a FastAPI TestClient.
tests/init.py Marks tests as a package (supports consistent discovery/import behavior).
src/static/styles.css Adds styling for the participants section and delete/unregister button.
src/static/index.html Adds cache-busting query strings to ensure updated JS/CSS are loaded.
src/static/app.js Renders participants per activity and adds unregister (DELETE) behavior from the UI.
src/app.py Adds activities, adds duplicate signup validation, and introduces the unregister endpoint.
requirements.txt Adds pytest dependency.
pytest.ini Configures pytest discovery to run tests from tests/ with test_*.py naming.

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

Comment thread src/static/app.js
Comment on lines 60 to 64
activityCard.innerHTML = `
<h4>${name}</h4>
<p>${details.description}</p>
<p><strong>Schedule:</strong> ${details.schedule}</p>
<p><strong>Availability:</strong> ${spotsLeft} spots left</p>
Comment thread src/static/app.js
Comment on lines +31 to +34
const participants = Array.isArray(details.participants) ? details.participants : [];
const maxParticipants = details.max_participants || 0;
const spotsLeft = maxParticipants - participants.length;
const encodedActivity = encodeURIComponent(name);
Comment thread src/app.py
Comment on lines +100 to 105
# 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}"}
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