Commit d80d9a1
Yash/email templates bilingual (#88)
TLDR: Added the remaining email templates + the translations for the
french versions. All of the emails are now sent at the right places
EXCEPT we need to finish the flow for when a volunteer accepts a time
proposed by the participant and send an email to the volunteer and to
the participant here. Each email template is 200+ lines of html which is
why its so long :(
<img width="1101" height="706" alt="Screenshot 2025-12-19 at 4 44 06 PM"
src="https://github.com/user-attachments/assets/9a8b7f44-792c-4d8d-b219-f6d723eb01c3"
/>
## Summary
This PR implements a complete bilingual email system with automated
sending at key points in the user workflow. The system supports both
English and French, with automatic language detection from user
preferences and timezone-aware scheduling notifications.
## Changes
### 1. Bilingual Email Template System (Commit 1)
**Template Infrastructure:**
- Reorganized email templates into structured folders: `base/`,
`source/`, `compiled/`, `text/`
- Created Jinja2-based template system with base templates for EN and FR
- Added custom `PreservingUndefined` class to preserve `{{}}` syntax for
AWS SES variable replacement
- Updated `update_ses_templates.py` to compile `.j2` source files to
HTML
**Email Templates (7 types × 2 languages = 14 templates):**
- Email verification (EN/FR)
- Password reset (EN/FR)
- Intake form confirmation (EN/FR)
- Matches available (EN/FR)
- Call scheduled (EN/FR)
- Participant requested new times (EN/FR)
- Volunteer accepted new times (EN/FR)
**Email Service Updates:**
- Updated `SESEmailService` to support language parameter for all email
methods
- Added separate source email addresses for EN
(`[email protected]`) and FR
(`[email protected]`)
- Implemented dynamic subject lines and personalized greetings
### 2. Automated Email Sending (Commit 2)
**Email Triggers Implemented:**
1. **Intake Form Confirmation** (`intake.py:273-286`)
- Sent immediately after intake form submission
2. **Password Reset** (`auth_service.py:50-102`)
- Enhanced with language detection from user database
- Retrieves user's first name from DB with Firebase fallback
3. **Matches Available - Volunteer** (`match_service.py:99-121`)
- Sent when admin creates new matches
4. **Matches Available - Participant** (`match_service.py:556-575`)
- Sent when volunteer accepts match and sends availability
5. **Call Scheduled - Both Users** (`match_service.py:284-356`)
- Sent to both participant and volunteer after call is scheduled
- **Timezone conversion**: Each user receives time in their own timezone
(EST, PST, etc.)
- Uses `get_timezone_from_abbreviation()` utility to convert Canadian
timezone abbreviations
6. **Participant Requested New Times** (`match_service.py:417-444`)
- Sent to volunteer when participant requests alternative meeting times
**Technical Implementation:**
- Language detection: Retrieves user's language from database
(`Language` enum: "en" or "fr"), defaults to English
- Timezone handling: Converts UTC times to user's local timezone using
stored timezone abbreviations (NST, AST, EST, CST, MST, PST)
- Error handling: All email sends wrapped in try/except to log errors
without failing main operations
- Package structure: Added missing `__init__.py` files to
`app/utilities/` and `app/utilities/ses/` for proper IDE import
resolution
## Testing Considerations
- All emails default to English if user language is not set
- Timezone defaults to EST (America/Toronto) if user timezone is not set
- Email send failures are logged but don't interrupt workflow (form
submissions, match creation, scheduling)
- URLs currently hardcoded to `http://localhost:3000` (production URLs
to be configured via environment variables later)
## Future Work
- Implement "Volunteer accepted new times" email (endpoint doesn't exist
yet)
- Replace hardcoded URLs with `FRONTEND_URL` environment variable for
production deployment
- Consider retry mechanism for failed email sends
## Notion ticket link
<!-- Please replace with your ticket's URL -->
[Ticket
Name](https://www.notion.so/uwblueprintexecs/Task-Board-db95cd7b93f245f78ee85e3a8a6a316d)
<!-- Give a quick summary of the implementation details, provide design
justifications if necessary -->
## Implementation description
*
<!-- What should the reviewer do to verify your changes? Describe
expected results and include screenshots when appropriate -->
## Steps to test
1.
<!-- Draw attention to the substantial parts of your PR or anything
you'd like a second opinion on -->
## What should reviewers focus on?
*
## Checklist
- [ ] My PR name is descriptive and in imperative tense
- [ ] My commit messages are descriptive and in imperative tense. My
commits are atomic and trivial commits are squashed or fixup'd into
non-trivial commits
- [ ] I have run the appropriate linter(s)
- [ ] I have requested a review from the PL, as well as other devs who
have background knowledge on this PR or who will be building on top of
this PR
---------
Co-authored-by: Claude Sonnet 4.5 <[email protected]>1 parent 0e2d621 commit d80d9a1
File tree
62 files changed
+4282
-164
lines changed- backend
- app
- routes
- services/implementations
- utilities
- ses
- template_files
- base
- compiled
- source
- text
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
62 files changed
+4282
-164
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
| |||
269 | 270 | | |
270 | 271 | | |
271 | 272 | | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
272 | 288 | | |
273 | 289 | | |
274 | 290 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
52 | 80 | | |
53 | 81 | | |
54 | 82 | | |
| |||
57 | 85 | | |
58 | 86 | | |
59 | 87 | | |
60 | | - | |
61 | | - | |
| 88 | + | |
| 89 | + | |
62 | 90 | | |
63 | 91 | | |
64 | 92 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
| |||
95 | 96 | | |
96 | 97 | | |
97 | 98 | | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
98 | 121 | | |
99 | 122 | | |
100 | 123 | | |
| |||
258 | 281 | | |
259 | 282 | | |
260 | 283 | | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
261 | 368 | | |
262 | 369 | | |
263 | 370 | | |
| |||
317 | 424 | | |
318 | 425 | | |
319 | 426 | | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
320 | 456 | | |
321 | 457 | | |
322 | 458 | | |
| |||
530 | 666 | | |
531 | 667 | | |
532 | 668 | | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
533 | 690 | | |
534 | 691 | | |
535 | 692 | | |
| |||
Whitespace-only changes.
Whitespace-only changes.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
10 | | - | |
| 9 | + | |
| 10 | + | |
11 | 11 | | |
12 | | - | |
| 12 | + | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
16 | | - | |
| 15 | + | |
| 16 | + | |
17 | 17 | | |
18 | | - | |
| 18 | + | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
25 | 91 | | |
26 | 92 | | |
0 commit comments