fix: update confirmation email, Stripe labels, and API team_preference #385
No reviewers
Labels
No labels
domain:backend
domain:devops
domain:frontend
status:approved
status:in-progress
status:needs-fix
status:qa
type:bug
type:devops
type:feature
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
forgejo_admin/basketball-api!385
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "383-fix-confirmation-email"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Replace hardcoded tryout-specific confirmation email with a generic registration confirmation that uses
load_email_template()for HTML rendering. Update Stripe product names and addteam_preferenceto the API registration endpoint.Changes
src/basketball_api/services/email.py:_build_confirmation_html()call withload_email_template("registration-confirmation", ...)with fallback to plaintext_build_confirmation_html()(~150 lines) and_build_credentials_html()(~25 lines) — no other callersteam_preferenceto admin registration notification (both plaintext and HTML)src/basketball_api/routes/register.py:team_preference: Optional[str] = NonetoAPIRegistrationRequestmodelteam_preferencehandling in API handler for both existing and new playersTest Plan
pytest tests/ -k "test_register or test_email"— 66 tests passregistration-confirmation.htmltemplate existsReview Checklist
Related Notes
None.
Related
Closes #383
PR #385 Review
DOMAIN REVIEW
Tech stack: Python / FastAPI / SQLAlchemy / Pydantic
email.py changes (confirmation email):
_build_confirmation_html()(~150 lines) and_build_credentials_html()(~25 lines) are both deleted entirely. Net -208 lines -- good cleanup.load_email_template("registration-confirmation", data)is called with propertry/except FileNotFoundErrorfallback tohtml_body = None, which will send plaintext-only. This is the correct graceful degradation pattern matching the existingload_email_template()function which raisesFileNotFoundErrorwhen the template file is missing.""when no credentials, inline HTML<p>block when present. Correctly usesescape()on credential email.team_preferenceadded to admin notification email (both plaintext and HTML table row). Usesplayer.team_preference.value if player.team_preference else "Not specified"-- correct enum access.register.py changes (Stripe + team_preference):
"Tryout Registration"/"Remote Registration"to"Registration"/"Remote Evaluation". Matches issue requirement.team_preference: Optional[str] = Noneadded toAPIRegistrationRequestPydantic model. Correct -- accepts string from API, parsed toTeamPreferenceenum internally.TeamPreference(body.team_preference.strip())withtry/except ValueError: passfor both existing and new player paths. Invalid values silently ignored (existing player keeps current value, new player getsNone).admin.py changes (is_public field):
is_public: booladded toAdminPlayerItemresponse model and populated in the player list endpoint.test_admin_spa.py changes:
"is_public"added to expected fields assertion for admin player list response. Test updated to match the model change.BLOCKERS
None.
load_email_template()has proper FileNotFoundError handling -- verified at/home/ldraney/basketball-api/src/basketball_api/services/email.py:1122-1125._build_confirmation_htmlhas no remaining callers after deletion (grep confirmed against repo).TeamPreferenceenum is an existing model field (/home/ldraney/basketball-api/src/basketball_api/models.py:213), not a schema change.NITS
Scope creep:
is_publicfield in admin.py -- TheAdminPlayerItem.is_publicaddition and test update are unrelated to issue #383 (confirmation email, Stripe label, team_preference). This is a minor addition (2 lines of production code, 1 line of test), but it should ideally be tracked separately. Not blocking since it is a trivial read-only field exposure that was already on the model.Silent team_preference rejection -- Invalid
team_preferencevalues are silently ignored (except ValueError: pass). The API caller gets no feedback that their value was rejected. Consider returning a 422 or including a warning in the response. Non-blocking since the field is optional and the behavior is safe.DRY: team_preference parsing duplicated -- The
TeamPreference(body.team_preference.strip())try/except block appears twice (once for existing player, once for new player). Could be extracted to a single parse before the if/else branch. Non-blocking.SOP COMPLIANCE
383-fix-confirmation-emailis_publicnoted above but non-blocking)fix:)PROCESS OBSERVATIONS
load_email_templatepattern is already proven (used by jersey-reminder email per/home/ldraney/basketball-api/tests/test_jersey_reminder.py). Good consistency.team_preferenceparsing or theis_publicfield addition, but existing registration tests cover the happy path and the changes are additive/optional fields.VERDICT: APPROVED
fc67ba4ae71a86670454