Improve student activity registration system#2
Merged
Conversation
There was a problem hiding this comment.
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 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 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 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}"} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
/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.src/app.py.Frontend Improvements:
styles.css. [1] [2]Testing and Configuration:
pytest.inito ensure tests are discovered and run from the correct paths.Other:
index.htmlto ensure cache busting for the latest JS and CSS changes. [1] [2]