feat(07-01): localized emails, locale-aware templates API, language preference endpoint

- email.py: send_invite_email() adds language param (en/es/pt), sends localized subject+body
- templates.py: list_templates()/get_template() accept ?locale= param, merge translations on response
- portal.py: PATCH /api/portal/users/me/language endpoint persists language preference
- portal.py: /api/portal/auth/verify response includes user.language field
- portal.py: AuthVerifyResponse adds language field (default 'en')
- test_portal_auth.py: fix _make_user mock to set language='en' (auto-fix Rule 1)
- test_language_preference.py: 4 integration tests for language preference endpoint
- test_templates_i18n.py: 5 integration tests for locale-aware templates (all passing)
This commit is contained in:
2026-03-25 16:27:14 -06:00
parent 7a3a4f0fdd
commit 9654982433
6 changed files with 648 additions and 38 deletions

View File

@@ -29,6 +29,7 @@ def _make_user(role: str, email: str = "test@example.com") -> PortalUser:
user.email = email
user.name = "Test User"
user.role = role
user.language = "en"
# Real bcrypt hash for password "testpassword"
user.hashed_password = bcrypt.hashpw(b"testpassword", bcrypt.gensalt()).decode()
user.created_at = datetime.now(tz=timezone.utc)