Skip to content

Add registration validation and more activities#2

Merged
sofiar-msft merged 3 commits intomainfrom
accelerate-with-copilot
Jun 23, 2025
Merged

Add registration validation and more activities#2
sofiar-msft merged 3 commits intomainfrom
accelerate-with-copilot

Conversation

@sofiar-msft
Copy link
Copy Markdown
Owner

This pull request introduces enhancements to the activity management system by adding new activities, improving validation for participant signup, and updating the UI to display participant information. Additionally, it includes styling updates for better visual presentation of participant details.

Backend Changes:

  • New Activities Added: Introduced multiple new activities categorized under sports, artistic, and intellectual themes, each with descriptions, schedules, maximum participant limits, and initial participants. (src/app.py, src/app.pyR41-R79)
  • Signup Validation: Added validation to prevent duplicate participant signups for the same activity, raising an HTTP exception if a student is already signed up. (src/app.py, src/app.pyR104-R107)

Frontend Changes:

  • Participant Information Display: Enhanced activity cards to display participant details, including a list of participants or a message indicating no participants yet. (src/static/app.js, src/static/app.jsL25-R35)
  • Styling for Participant Section: Added CSS styles for the participant section, including background color, padding, and improved list formatting for participant names. (src/static/styles.css, src/static/styles.cssR145-R167)

@sofiar-msft sofiar-msft requested a review from Copilot June 23, 2025 20:35
@sofiar-msft sofiar-msft merged commit 8e63443 into main Jun 23, 2025
3 checks passed
Copy link
Copy Markdown

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 expands the set of activities, adds a check to prevent duplicate signups, and updates the UI to list participants with accompanying styles.

  • Introduces sports, artistic, and intellectual activities in the backend
  • Adds signup validation to reject duplicate participant registrations
  • Enhances frontend cards to display participant lists and applies new CSS for styling

Reviewed Changes

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

File Description
src/app.py Added new activities and a duplicate-signup validation in signup_for_activity
src/static/app.js Updated activity card markup to include a participants section and relabeled fields
src/static/styles.css Added styles for .participants-section and .participants-list
Comments suppressed due to low confidence (1)

src/app.py:105

  • Consider adding a test case to cover the duplicate signup validation path, ensuring the HTTP 400 error is thrown as expected.
    if email in activity["participants"]:

Comment on lines +32 to +33
? details.participants.map(p => `<li>${p}</li>`).join('')
: '<li><em>No participants yet</em></li>'}
Copy link

Copilot AI Jun 23, 2025

Choose a reason for hiding this comment

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

Rendering participant names directly via innerHTML opens a risk for XSS if the data isn't sanitized. Consider using DOM methods or sanitizing input before insertion.

Suggested change
? details.participants.map(p => `<li>${p}</li>`).join('')
: '<li><em>No participants yet</em></li>'}
? (() => {
const participantsList = document.createDocumentFragment();
details.participants.forEach(p => {
const listItem = document.createElement("li");
listItem.textContent = p;
participantsList.appendChild(listItem);
});
return participantsList;
})()
: (() => {
const noParticipantsItem = document.createElement("li");
noParticipantsItem.innerHTML = "<em>No participants yet</em>";
return noParticipantsItem.outerHTML;
})()}

Copilot uses AI. Check for mistakes.
<p><strong>Description:</strong> ${details.description}</p>
<p><strong>Schedule:</strong> ${details.schedule}</p>
<p><strong>Availability:</strong> ${spotsLeft} spots left</p>
<p><strong>Max Participants:</strong> ${details.max_participants}</p>
Copy link

Copilot AI Jun 23, 2025

Choose a reason for hiding this comment

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

[nitpick] Previously the UI displayed available spots; consider also computing and showing remaining slots (max_participants minus current participants) to maintain consistency in availability info.

Suggested change
<p><strong>Max Participants:</strong> ${details.max_participants}</p>
<p><strong>Max Participants:</strong> ${details.max_participants}</p>
<p><strong>Remaining Slots:</strong> ${spotsLeft}</p>

Copilot uses AI. Check for mistakes.
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.

2 participants