Add registration validation and more activities#2
Merged
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR expands the set of available activities, prevents duplicate signups on the backend, and updates the frontend to display participant lists with new styling.
- Backend: added new activity entries and duplicate‐signup validation
- Frontend: renders participant lists in each activity card
- Styling: introduced CSS rules for the participants section
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/app.py | Added sports, artistic, and intellectual activities; implemented duplicate signup check |
| src/static/app.js | Injects a <ul> of participants (or placeholder) into each activity card |
| src/static/styles.css | Defines layout and styling for .participants-section and .participants-list |
Comments suppressed due to low confidence (3)
src/app.py:106
- [nitpick] A 400 status is generic for this case—using 409 Conflict would more accurately convey that the signup request conflicts with existing registration.
raise HTTPException(status_code=400, detail="Student already signed up")
src/app.py:104
- The new duplicate‐signup branch should have corresponding unit tests to ensure the HTTPException is raised correctly and that valid signups still succeed.
# Validate student is not already signed up
src/static/app.js:31
- Interpolating
pdirectly into HTML can open an XSS vulnerability if participant data isn’t sanitized. Consider creating<li>elements via DOM APIs or escapingpbefore insertion.
${details.participants.length > 0 ? details.participants.map(p => `<li>${p}</li>`).join("") : '<li><em>No participants yet</em></li>'}
| # Validate student is not already signed up | ||
| if email in activity["participants"]: | ||
| raise HTTPException(status_code=400, detail="Student already signed up") | ||
|
|
There was a problem hiding this comment.
Currently there’s no check against max_participants. You should validate len(activity['participants']) < activity['max_participants'] before appending to prevent overbooking.
Suggested change
| # Validate activity is not overbooked | |
| if len(activity["participants"]) >= activity["max_participants"]: | |
| raise HTTPException(status_code=400, detail="Activity is fully booked") |
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 new activity options, enhances the signup validation logic, and improves the user interface to display participant details. The most important changes include adding new activities, validating duplicate signups, and updating the frontend to show participant lists with styling.
Backend Changes:
activitiesdictionary insrc/app.pyto include sports, artistic, and intellectual activities such as Soccer Team, Art Club, and Math Olympiad. Each activity includes a description, schedule, maximum participants, and initial participant list.signup_for_activityfunction insrc/app.pyto prevent students from signing up for an activity multiple times. Throws an HTTPException if the student is already signed up.Frontend Changes:
src/static/app.jsfile to show a list of participants for each activity on the activity card. Displays "No participants yet" if the list is empty.src/static/styles.cssfor the participant section, including background color, padding, and list formatting to enhance visual presentation.