email: Add a space after the time and AM/PM in the login email.

This is more typical formatting for times.

Fixes #27727.
This commit is contained in:
kimry02 2023-11-27 12:47:30 -05:00 committed by GitHub
parent d6a2bbc2ef
commit adc11e5ba2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 2 deletions

View File

@ -100,7 +100,7 @@ def email_on_new_login(sender: Any, user: UserProfile, request: Any, **kwargs: A
if user.twenty_four_hour_time: if user.twenty_four_hour_time:
hhmm_string = local_time.strftime("%H:%M") hhmm_string = local_time.strftime("%H:%M")
else: else:
hhmm_string = local_time.strftime("%I:%M%p") hhmm_string = local_time.strftime("%I:%M %p")
context["login_time"] = local_time.strftime(f"%A, %B %d, %Y at {hhmm_string} %Z") context["login_time"] = local_time.strftime(f"%A, %B %d, %Y at {hhmm_string} %Z")
context["device_ip"] = request.META.get("REMOTE_ADDR") or _("Unknown IP address") context["device_ip"] = request.META.get("REMOTE_ADDR") or _("Unknown IP address")
context["device_os"] = get_device_os(user_agent) or _("an unknown operating system") context["device_os"] = get_device_os(user_agent) or _("an unknown operating system")

View File

@ -54,7 +54,7 @@ class SendLoginEmailTest(ZulipTestCase):
) )
user_tz = zoneinfo.ZoneInfo(user.timezone) user_tz = zoneinfo.ZoneInfo(user.timezone)
mock_time = datetime.datetime(year=2018, month=1, day=1, tzinfo=datetime.timezone.utc) mock_time = datetime.datetime(year=2018, month=1, day=1, tzinfo=datetime.timezone.utc)
reference_time = mock_time.astimezone(user_tz).strftime("%A, %B %d, %Y at %I:%M%p %Z") reference_time = mock_time.astimezone(user_tz).strftime("%A, %B %d, %Y at %I:%M %p %Z")
with mock.patch("zerver.signals.timezone_now", return_value=mock_time): with mock.patch("zerver.signals.timezone_now", return_value=mock_time):
self.client_post( self.client_post(
"/accounts/login/", info=login_info, HTTP_USER_AGENT=firefox_windows "/accounts/login/", info=login_info, HTTP_USER_AGENT=firefox_windows