fix: set html lang on outbound emails based on service branding#2915
Closed
smcmurtry wants to merge 3 commits into
Closed
fix: set html lang on outbound emails based on service branding#2915smcmurtry wants to merge 3 commits into
smcmurtry wants to merge 3 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates outbound HTML email rendering options to include an explicit lang value derived from service branding, so the HTML template can set the document language appropriately.
Changes:
- Add
langtoget_html_email_options, returning"fr"for French default branding /BRANDING_BOTH_FR, otherwise"en". - Update existing
get_html_email_optionstests to assert the newlangkey for branded and default-English cases.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
app/delivery/send_to_providers.py |
Adds lang to the HTML email options dict that is splatted into HTMLEmailTemplate(...). |
tests/app/delivery/test_send_to_providers.py |
Updates tests to assert lang for branding types and the default English branch. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
532
to
537
| "brand_text": service.email_branding.text, | ||
| "brand_name": service.email_branding.name, | ||
| "alt_text_en": service.email_branding.alt_text_en, | ||
| "alt_text_fr": service.email_branding.alt_text_fr, | ||
| "lang": "fr" if service.email_branding.brand_type == BRANDING_BOTH_FR else "en", | ||
| } |
Comment on lines
840
to
853
| def test_get_html_email_renderer_with_branding_details_and_render_fip_banner_english_only(notify_db, sample_service): | ||
| sample_service.email_branding = None | ||
| notify_db.session.add_all([sample_service]) | ||
| notify_db.session.commit() | ||
| options = send_to_providers.get_html_email_options(sample_service) | ||
|
|
||
| assert options == { | ||
| "fip_banner_english": True, | ||
| "fip_banner_french": False, | ||
| "logo_with_background_colour": False, | ||
| "alt_text_en": None, | ||
| "alt_text_fr": None, | ||
| "lang": "en", | ||
| } |
Contributor
Author
|
Closing since I can't actually see this language attribute when manually testing in gmail |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary | Résumé
Pair with notification-utils PR cds-snc/notification-utils#415.
get_html_email_optionsnow returns alangvalue that is splatted intoHTMLEmailTemplate(**…):"fr"when the service usesBRANDING_BOTH_FRor hasdefault_branding_is_french=Trueand no email_branding."en"otherwise.Existing
get_html_email_optionstests updated to assert the new key.Requires notifications-utils bump that adds the
langkwarg.Related Issues | Cartes liées
Test instructions | Instructions pour tester la modification
TBD
Release Instructions | Instructions pour le déploiement
None.
Reviewer checklist | Liste de vérification du réviseur