Skip to content

Implement various fixes and add tests - #2

Merged
KevinSebastin merged 4 commits into
mainfrom
accelerate-with-copilot
May 27, 2026
Merged

KevinSebastin merged 4 commits into
mainfrom
accelerate-with-copilot

Conversation

@KevinSebastin

Copy link
Copy Markdown
Owner

No description provided.

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 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}/unregister API 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 thread src/static/app.js
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 thread src/app.py
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 thread src/app.py
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)
@KevinSebastin
KevinSebastin merged commit 35ced03 into main May 27, 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.

3 participants