Skip to content

Improve student activity registration system#2

Merged
mrobardsKO merged 7 commits intomainfrom
accelerate-with-copilot
Mar 4, 2026
Merged

Improve student activity registration system#2
mrobardsKO merged 7 commits intomainfrom
accelerate-with-copilot

Conversation

@mrobardsKO
Copy link
Copy Markdown
Owner

This pull request adds new features for managing participants in school activities, improves the frontend to display and allow removal of participants, and introduces comprehensive backend and frontend validation. It also adds automated tests and test fixtures to ensure reliability and prevent regressions. The changes are grouped below by theme.

Backend features and validation:

  • Added a new endpoint to unregister a student from an activity (unregister_from_activity) with validation for activity existence and participant status.
  • Enhanced signup logic to prevent duplicate registrations by checking if a student is already signed up before adding them.

Frontend improvements:

  • Updated the frontend (app.js) to fetch activities with cache-busting and display participants for each activity, including a button to remove participants.
  • Added event handling in the frontend to support participant removal, including error handling and UI feedback.
  • Improved frontend styles to clearly display participants and provide visual feedback for removal actions.

Testing and reliability:

  • Added automated tests for activity signup, duplicate prevention, participant removal, and error cases, covering both success and failure scenarios.
  • Introduced a pytest fixture to reset the activities state between tests, ensuring test isolation and reliability.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f6d96998a1

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Copy link
Copy Markdown
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 PR enhances the student activity registration system by adding participant management (duplicate prevention + unregister support), updating the frontend to display and remove participants, and introducing pytest-based API tests.

Changes:

  • Backend: prevent duplicate signups and add an unregister endpoint.
  • Frontend: render participant lists per activity and support unregister via a remove button.
  • Testing: add pytest fixtures + API tests for success and failure cases.

Reviewed changes

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

Show a summary per file
File Description
src/app.py Adds duplicate-signup validation and a DELETE endpoint to unregister participants; expands seeded activities.
src/static/app.js Adds cache-busted activity fetching, renders participants, and implements unregister UI flow.
src/static/styles.css Adds participant list / remove-button styling.
tests/conftest.py Adds FastAPI TestClient fixture and autouse state reset for the in-memory activities store.
tests/test_app.py Adds API tests for listing activities, signup, duplicate prevention, and unregister behavior.
requirements.txt Adds pytest dependency.

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

});

activitiesList.addEventListener("click", async (event) => {
const removeButton = event.target.closest(".participant-remove-btn");
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

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

event.target is not guaranteed to be an Element (it can be a Text node), so calling event.target.closest(...) can throw at runtime. Guard with an instanceof Element check (or use event.composedPath() / start from event.target.parentElement) before calling .closest.

Suggested change
const removeButton = event.target.closest(".participant-remove-btn");
const target = event.target;
if (!(target instanceof Element)) {
return;
}
const removeButton = target.closest(".participant-remove-btn");

Copilot uses AI. Check for mistakes.
Comment on lines +101 to 106
# Validate student is not already signed up
if email in activity["participants"]:
raise HTTPException(status_code=400, detail="Student already signed up")

# Add student
activity["participants"].append(email)
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

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

The backend accepts email as an unconstrained str and stores it directly. This makes duplicates easy to bypass via case/whitespace differences (e.g., User@... vs user@...) and allows non-email / potentially unsafe strings to be persisted and later rendered by the frontend. Consider validating and normalizing the email (e.g., pydantic.EmailStr + strip() + lowercase) before checking membership / appending.

Copilot uses AI. Check for mistakes.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@mrobardsKO
Copy link
Copy Markdown
Owner Author

@copilot open a new pull request to apply changes based on the comments in this thread

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 4, 2026

@mrobardsKO 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.

Copilot AI and others added 2 commits March 4, 2026 17:38
…alization in app.py

Co-authored-by: mrobardsKO <113369208+mrobardsKO@users.noreply.github.com>
Harden registration system: XSS-safe DOM, email normalization, instanceof guard
@mrobardsKO mrobardsKO merged commit 0397eb7 into main Mar 4, 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