emails: Display the timezone's name on login notifications.

Show the timezone's name instead of the UTC offset, since it's easier to
infer where does the login come from that way.
This commit is contained in:
Yago González 2018-08-04 11:05:12 +02:00 committed by Tim Abbott
parent 27d4b1a5f0
commit 75b39866c7
2 changed files with 3 additions and 4 deletions

View File

@ -79,8 +79,7 @@ def email_on_new_login(sender: Any, user: UserProfile, request: Any, **kwargs: A
if user_tz == '':
user_tz = timezone_get_current_timezone_name()
local_time = timezone_now().astimezone(get_timezone(user_tz))
utc_offset = local_time.strftime('%z')
context['login_time'] = local_time.strftime('%A, %B %d, %Y at %I:%M%p ') + utc_offset
context['login_time'] = local_time.strftime('%A, %B %d, %Y at %I:%M%p %Z')
context['device_ip'] = request.META.get('REMOTE_ADDR') or _("Unknown IP address")
context['device_os'] = get_device_os(user_agent)
context['device_browser'] = get_device_browser(user_agent)

View File

@ -35,8 +35,8 @@ class SendLoginEmailTest(ZulipTestCase):
password = initial_password(user.email)
firefox_windows = "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:47.0) Gecko/20100101 Firefox/47.0"
user_tz = get_timezone(user.timezone)
utc_offset = mock_time.astimezone(user_tz).strftime('%z')
reference_time = mock_time.astimezone(user_tz).strftime('%A, %B %d, %Y at %I:%M%p ') + utc_offset
mock_time = datetime.datetime(year=2018, month=1, day=1, tzinfo=utc)
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):
self.client_post("/accounts/login/", info={"username": user.email, "password": password},
HTTP_USER_AGENT=firefox_windows)