Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 14 additions & 10 deletions app/backend/src/couchers/email/emails.py
Original file line number Diff line number Diff line change
Expand Up @@ -688,8 +688,8 @@ def build_body(self, builder: EmailBlocksBuilder, loc_context: LocalizationConte
self.surfer,
"date_range",
{
"from_date": loc_context.localize_date(self.from_date),
"to_date": loc_context.localize_date(self.to_date),
"from_date": _localize_host_request_date(self.from_date, loc_context),
"to_date": _localize_host_request_date(self.to_date, loc_context),
},
)
builder.quote(self.text, markdown=False)
Expand Down Expand Up @@ -745,8 +745,8 @@ def build_body(self, builder: EmailBlocksBuilder, loc_context: LocalizationConte
self.surfer,
".host_request_generic.date_range",
{
"from_date": loc_context.localize_date(self.from_date),
"to_date": loc_context.localize_date(self.to_date),
"from_date": _localize_host_request_date(self.from_date, loc_context),
"to_date": _localize_host_request_date(self.to_date, loc_context),
},
)
builder.action(self.view_link, ".host_request_generic.view_action")
Expand Down Expand Up @@ -798,8 +798,8 @@ def build_body(self, builder: EmailBlocksBuilder, loc_context: LocalizationConte
self.other_user,
".host_request_generic.date_range",
{
"from_date": loc_context.localize_date(self.from_date),
"to_date": loc_context.localize_date(self.to_date),
"from_date": _localize_host_request_date(self.from_date, loc_context),
"to_date": _localize_host_request_date(self.to_date, loc_context),
},
)
builder.quote(self.text, markdown=False)
Expand Down Expand Up @@ -860,8 +860,8 @@ def build_body(self, builder: EmailBlocksBuilder, loc_context: LocalizationConte
self.other_user,
".host_request_generic.date_range",
{
"from_date": loc_context.localize_date(self.from_date),
"to_date": loc_context.localize_date(self.to_date),
"from_date": _localize_host_request_date(self.from_date, loc_context),
"to_date": _localize_host_request_date(self.to_date, loc_context),
},
)
builder.action(self.view_link, ".host_request_generic.view_action")
Expand Down Expand Up @@ -929,8 +929,8 @@ def build_body(self, builder: EmailBlocksBuilder, loc_context: LocalizationConte
self.other_user,
".host_request_generic.date_range",
{
"from_date": loc_context.localize_date(self.from_date),
"to_date": loc_context.localize_date(self.to_date),
"from_date": _localize_host_request_date(self.from_date, loc_context),
"to_date": _localize_host_request_date(self.to_date, loc_context),
},
)
builder.action(self.view_link, ".host_request_generic.view_action")
Expand Down Expand Up @@ -1312,3 +1312,7 @@ def dummy_data(cls) -> ThreadReplyEmail:
markdown_text="I agree, the Grünewald is **amazing**!",
view_link="https://couchers.org/discussions/123",
)


def _localize_host_request_date(value: date, loc_context: LocalizationContext) -> str:
return loc_context.localize_date(value, with_year=False, with_day_of_week=True)
24 changes: 12 additions & 12 deletions app/backend/src/tests/test_requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -1441,10 +1441,10 @@ def test_request_notifications(db, push_collector: PushCollector, moderator):
assert "quick decline" in e.html.lower()
assert surfer.name in e.plain
assert surfer.name in e.html
assert host_loc_context.localize_date(today_plus_2) in e.plain
assert host_loc_context.localize_date(today_plus_2) in e.html
assert host_loc_context.localize_date(today_plus_3) in e.plain
assert host_loc_context.localize_date(today_plus_3) in e.html
assert host_loc_context.localize_date(today_plus_2, with_year=False) in e.plain
assert host_loc_context.localize_date(today_plus_2, with_year=False) in e.html
assert host_loc_context.localize_date(today_plus_3, with_year=False) in e.plain
assert host_loc_context.localize_date(today_plus_3, with_year=False) in e.html
assert "http://localhost:5001/img/thumbnail/" not in e.plain
assert "http://localhost:5001/img/thumbnail/" in e.html
assert f"http://localhost:3000/messages/request/{hr_id}" in e.plain
Expand All @@ -1470,10 +1470,10 @@ def test_request_notifications(db, push_collector: PushCollector, moderator):
assert host.name in e.html
assert surfer.name in e.plain
assert surfer.name in e.html
assert surfer_loc_context.localize_date(today_plus_2) in e.plain
assert surfer_loc_context.localize_date(today_plus_2) in e.html
assert surfer_loc_context.localize_date(today_plus_3) in e.plain
assert surfer_loc_context.localize_date(today_plus_3) in e.html
assert surfer_loc_context.localize_date(today_plus_2, with_year=False) in e.plain
assert surfer_loc_context.localize_date(today_plus_2, with_year=False) in e.html
assert surfer_loc_context.localize_date(today_plus_3, with_year=False) in e.plain
assert surfer_loc_context.localize_date(today_plus_3, with_year=False) in e.html
assert "http://localhost:5001/img/thumbnail/" not in e.plain
assert "http://localhost:5001/img/thumbnail/" in e.html
assert f"http://localhost:3000/messages/request/{hr_id}" in e.plain
Expand Down Expand Up @@ -1515,10 +1515,10 @@ def test_quick_decline(db, push_collector: PushCollector, moderator):
assert "quick decline" in e.html.lower()
assert surfer.name in e.plain
assert surfer.name in e.html
assert host_loc_context.localize_date(today_plus_2) in e.plain
assert host_loc_context.localize_date(today_plus_2) in e.html
assert host_loc_context.localize_date(today_plus_3) in e.plain
assert host_loc_context.localize_date(today_plus_3) in e.html
assert host_loc_context.localize_date(today_plus_2, with_year=False) in e.plain
assert host_loc_context.localize_date(today_plus_2, with_year=False) in e.html
assert host_loc_context.localize_date(today_plus_3, with_year=False) in e.plain
assert host_loc_context.localize_date(today_plus_3, with_year=False) in e.html
assert "http://localhost:5001/img/thumbnail/" not in e.plain
assert "http://localhost:5001/img/thumbnail/" in e.html
assert f"http://localhost:3000/messages/request/{hr_id}" in e.plain
Expand Down
Loading