Skip to content

Commit 201b8cf

Browse files
Backend/emails: Take links out of loc files.
1 parent 7211732 commit 201b8cf

2 files changed

Lines changed: 23 additions & 7 deletions

File tree

app/backend/src/couchers/email/emails.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from typing import Self, assert_never
99

1010
from markupsafe import Markup, escape
11+
from urllib.parse import urlencode
1112

1213
from couchers import urls
1314
from couchers.config import config
@@ -513,7 +514,7 @@ def get_body_blocks(self, loc_context: LocalizationContext) -> list[EmailBlock]:
513514
builder.para(".invoice_receipt_info")
514515
builder.action(self.receipt_url, ".download_invoice")
515516
builder.para(".tax_acknowledgment")
516-
builder.para(".questions_contact")
517+
builder.para(".questions_contact", { "email": _email_link_markup("donations@couchers.org")})
517518
builder.para(".generosity_helps")
518519
builder.para(".thank_you")
519520
builder.para("generic.founders_signature")
@@ -1665,14 +1666,20 @@ def get_body_blocks(self, loc_context: LocalizationContext) -> list[EmailBlock]:
16651666
builder.para(".link", {"url": urls.app_link()})
16661667
builder.para(".platform_under_development")
16671668
builder.para(".thanks_for_joining")
1668-
builder.para(".signature")
1669+
builder.para(".signature", {
1670+
"email_link": _email_link_markup("aapeliv@couchers.org"),
1671+
"profile_link": _link_markup("https://couchers.org/user/aapeli")
1672+
})
16691673
else:
16701674
builder.para(".intro")
16711675
builder.para(".fill_in_profile")
16721676
builder.action(edit_profile_url, ".edit_profile_action")
16731677
builder.para(".no_empty_accounts")
16741678
builder.para(".profile_importance")
1675-
builder.para(".signature")
1679+
builder.para(".signature", {
1680+
"email_link": _email_link_markup("community@couchers.org"),
1681+
"profile_link": _link_markup("https://couchers.org/user/emily")
1682+
})
16761683
return builder.build()
16771684

16781685
@classmethod
@@ -2039,3 +2046,12 @@ def test_instances(cls) -> list[Self]:
20392046

20402047
def _localize_host_request_date(value: date, loc_context: LocalizationContext) -> str:
20412048
return loc_context.localize_date(value, with_year=False, with_day_of_week=True)
2049+
2050+
def _email_link_markup(email: str, subject: str | None = None) -> Markup:
2051+
url = f"mailto:{email}"
2052+
if subject:
2053+
url += f"?subject={urlencode(subject)}"
2054+
return _link_markup(url, text=email)
2055+
2056+
def _link_markup(url: str, *, text: str | None = None) -> Markup:
2057+
return Markup(f'<a href="{escape(url)}">{escape(text or url)}</a>')

app/backend/src/couchers/email/locales/en.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"greeting_line": "Hi {{name}},",
44
"closing_line": "Best,<br>The Couchers.org Team",
55
"founders_signature": "Aapeli and Itsi,<br>Couchers.org Founders",
6-
"security_warning_contact_support": "If you did not initiate this action, please contact us by emailing <a href=\"mailto:support@couchers.org\">support@couchers.org</a> so we can sort this out as soon as possible!",
6+
"security_warning_contact_support": "If you did not initiate this action, please contact us by emailing {{ email_link }} so we can sort this out as soon as possible!",
77
"do_not_reply_request": "<b>Do not reply to this email.</b> Use one of the buttons above to reply to this request."
88
},
99
"calendar_events": {
@@ -112,7 +112,7 @@
112112
"invoice_receipt_info": "You can download an invoice and receipt for the donation here:",
113113
"download_invoice": "Download invoice",
114114
"tax_acknowledgment": "Couchers, Inc. is a 501(c)(3) nonprofit (EIN: 87-1734577) registered in the United States. No goods or services were provided in exchange for this contribution.",
115-
"questions_contact": "If you have any questions about your donation, please email us at <a href=\"mailto:donations@couchers.org\">donations@couchers.org</a>.",
115+
"questions_contact": "If you have any questions about your donation, please email us at {{ email }}.",
116116
"generosity_helps": "Your generosity will help deliver the platform for everyone.",
117117
"thank_you": "Thank you!"
118118
},
@@ -272,7 +272,7 @@
272272
"link": "Link: <a href=\"{{ url }}\">{{ url }}",
273273
"platform_under_development": "The platform is still under development, and features are actively being built by our amazing team of Couchers.org contributors around the world. We would like to hear your feedback and thoughts on what we've built and what we're working on.",
274274
"thanks_for_joining": "Thanks so much for joining the platform. We're really excited to have you here and as part of our growing community!",
275-
"signature": "Aapeli<br>Couchers.org Co-founder<br><a href=\"mailto:aapeli@couchers.org\">aapeli@couchers.org</a> (feel free to shoot me an email at any time)<br><br><a href=\"https://couchers.org/user/aapeli\">https://couchers.org/user/aapeli</a>"
275+
"signature": "Aapeli<br>Couchers.org Co-founder<br>{{ email_link }} (feel free to shoot me an email at any time)<br><br>{{ profile_link }}"
276276
},
277277
"follow_up": {
278278
"subject": "Complete your profile on Couchers.org",
@@ -281,7 +281,7 @@
281281
"edit_profile_action": "Go to edit your profile",
282282
"no_empty_accounts": "A big problem that some platforms have is that there are so many empty accounts, and we really want to avoid that!",
283283
"profile_importance": "We would really appreciate it if you could add a photo and fill in at least the \"Who I am\" section of your profile, although a full profile would be even better! It's an easy way to help showcase the amazing community we're building together, and it means you'll be fully ready to connect, host, or surf as the community thrives.",
284-
"signature": "Emily from Couchers.org<br><a href=\"mailto:community@couchers.org\">community@couchers.org</a><br><br><a href=\"https://couchers.org/user/emily\">https://couchers.org/user/emily</a>"
284+
"signature": "Emily from Couchers.org<br>{{ email_link }}<br><br>{{ profile_link }}"
285285
}
286286
},
287287
"password_changed": {

0 commit comments

Comments
 (0)