Repository navigation
Implement various fixes and add tests - #2
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds backend and frontend support for unregistering participants, improves the activities UI to show participant lists with remove controls, and introduces a pytest suite covering core API behaviors.
Changes:
- Added duplicate-signup validation and a new
/activities/{activity_name}/unregisterAPI endpoint. - Updated the frontend to render participant lists, show loading state, and allow unregistering from the UI.
- Added pytest fixtures and new tests for root redirect, activities listing, signup, and unregister flows.
Reviewed changes
Copilot reviewed 8 out of 9 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
src/app.py |
Adds duplicate signup protection, introduces an unregister endpoint, and expands seeded activities data. |
src/static/app.js |
Adds loading UI, centralized messaging, participant list rendering, and unregister actions from the UI. |
src/static/styles.css |
Styles for the loading state and participant list/remove button UI. |
tests/conftest.py |
Introduces a TestClient fixture and an autouse fixture to reset global activities state between tests. |
tests/test_activities.py |
Tests /activities returns expected seeded structure. |
tests/test_root.py |
Tests / redirects to /static/index.html. |
tests/test_signup_unregister.py |
Tests signup success/duplicate/unknown activity and unregister success/non-member/unknown activity. |
requirements.txt |
Adds pytest to support the new test suite. |
.vscode/settings.json |
Adds a VS Code setting related to auto-approving running pytest. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+43
to
+56
| const participantsList = details.participants.length | ||
| ? details.participants | ||
| .map( | ||
| (participant) => ` | ||
| <li class="participant-item"> | ||
| <span class="participant-email">${participant}</span> | ||
| <button | ||
| type="button" | ||
| class="participant-remove-btn" | ||
| data-activity="${encodeURIComponent(name)}" | ||
| data-email="${encodeURIComponent(participant)}" | ||
| aria-label="Remove ${participant} from ${name}" | ||
| title="Unregister participant" | ||
| > |
Comment on lines
91
to
+104
| @app.post("/activities/{activity_name}/signup") | ||
| def signup_for_activity(activity_name: str, email: str): | ||
| """Sign up a student for an activity""" | ||
| # Validate activity exists | ||
| if activity_name not in activities: | ||
| raise HTTPException(status_code=404, detail="Activity not found") | ||
|
|
||
| # 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") | ||
|
|
Comment on lines
+110
to
+121
| @app.post("/activities/{activity_name}/unregister") | ||
| def unregister_from_activity(activity_name: str, email: str): | ||
| """Unregister a student from an activity""" | ||
| if activity_name not in activities: | ||
| raise HTTPException(status_code=404, detail="Activity not found") | ||
|
|
||
| activity = activities[activity_name] | ||
|
|
||
| if email not in activity["participants"]: | ||
| raise HTTPException(status_code=400, detail="Student is not signed up for this activity") | ||
|
|
||
| activity["participants"].remove(email) |
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.
No description provided.