feat: implement Phase 3 participant self-management (stories 4.5, 6.1)

Implemented features:
- Story 4.5: View Participant List - participants can see other active participants
- Story 6.1: Update Profile - participants can edit name and gift ideas before matching
- Utility functions for state management and business logic
- Comprehensive unit and integration tests

New files:
- src/utils/participant.py - Business logic utilities
- src/templates/participant/profile_edit.html - Profile edit form
- tests/unit/test_participant_utils.py - Unit tests for utilities
- tests/integration/test_participant_list.py - Integration tests for participant list
- tests/integration/test_profile_update.py - Integration tests for profile updates

Modified files:
- src/routes/participant.py - Added dashboard participant list and profile edit route
- src/templates/participant/dashboard.html - Added participant list section and edit link
- src/forms/participant.py - Added ProfileUpdateForm
- src/app.py - Added participant.profile_edit to setup check exemptions
- tests/conftest.py - Added exchange_factory, participant_factory, auth_participant fixtures

All tests passing. Phase 3.3 (reminder preferences) and 3.4 (withdrawal) remain to be implemented.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2025-12-22 20:05:28 -07:00
parent 75378ac769
commit a7902aa623
10 changed files with 709 additions and 1 deletions

55
src/utils/participant.py Normal file
View File

@@ -0,0 +1,55 @@
"""Participant business logic utilities."""
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from src.models import Participant
def get_active_participants(exchange_id: int) -> list["Participant"]:
"""Get all active (non-withdrawn) participants for an exchange.
Args:
exchange_id: ID of the exchange
Returns:
List of active participants, ordered by name
"""
from src.models.participant import Participant
result: list[Participant] = (
Participant.query.filter(
Participant.exchange_id == exchange_id, Participant.withdrawn_at.is_(None)
)
.order_by(Participant.name)
.all()
)
return result
def is_withdrawn(participant: "Participant") -> bool:
"""Check if participant has withdrawn.
Args:
participant: The participant to check
Returns:
True if withdrawn, False otherwise
"""
return participant.withdrawn_at is not None
def can_update_profile(participant: "Participant") -> bool:
"""Check if participant can update their profile.
Profile updates are allowed until matching occurs.
Args:
participant: The participant to check
Returns:
True if profile updates are allowed, False otherwise
"""
exchange = participant.exchange
allowed_states = ["draft", "registration_open", "registration_closed"]
return exchange.state in allowed_states