mirror of https://github.com/zulip/zulip.git
timezone: Remove get_all_timezones wrapper.
Both callers want a set, and pytz already provides all_timezones_set. Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
parent
3a4b38d732
commit
0134112b51
|
@ -1,12 +1,9 @@
|
|||
import datetime
|
||||
from typing import Any, Dict, List, Union
|
||||
from typing import Any, Dict, Union
|
||||
|
||||
import pytz
|
||||
|
||||
|
||||
def get_all_timezones() -> List[str]:
|
||||
return sorted(pytz.all_timezones)
|
||||
|
||||
def get_timezone(tz: str) -> pytz.BaseTzInfo:
|
||||
return pytz.timezone(tz)
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ import smtplib
|
|||
import urllib
|
||||
from typing import Dict, List, Optional
|
||||
|
||||
import pytz
|
||||
from django.conf import settings
|
||||
from django.contrib.auth import authenticate, get_backends
|
||||
from django.core import validators
|
||||
|
@ -50,7 +51,6 @@ from zerver.lib.pysa import mark_sanitized
|
|||
from zerver.lib.send_email import FromAddress, send_email
|
||||
from zerver.lib.sessions import get_expirable_session_var
|
||||
from zerver.lib.subdomains import get_subdomain, is_root_domain_available
|
||||
from zerver.lib.timezone import get_all_timezones
|
||||
from zerver.lib.url_encoding import add_query_to_redirect_url
|
||||
from zerver.lib.users import get_accounts_for_email
|
||||
from zerver.lib.zephyr import compute_mit_user_fullname
|
||||
|
@ -290,7 +290,7 @@ def accounts_register(request: HttpRequest) -> HttpResponse:
|
|||
default_stream_groups = lookup_default_stream_groups(default_stream_group_names, realm)
|
||||
|
||||
timezone = ""
|
||||
if 'timezone' in request.POST and request.POST['timezone'] in get_all_timezones():
|
||||
if 'timezone' in request.POST and request.POST['timezone'] in pytz.all_timezones_set:
|
||||
timezone = request.POST['timezone']
|
||||
|
||||
if 'source_realm' in request.POST and request.POST["source_realm"] != "on":
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
from typing import Any, Dict, Optional
|
||||
|
||||
import pytz
|
||||
from django.conf import settings
|
||||
from django.contrib.auth import authenticate, update_session_auth_hash
|
||||
from django.core.exceptions import ValidationError
|
||||
|
@ -40,7 +41,6 @@ from zerver.lib.rate_limiter import RateLimited
|
|||
from zerver.lib.request import JsonableError
|
||||
from zerver.lib.response import json_error, json_success
|
||||
from zerver.lib.send_email import FromAddress, send_email
|
||||
from zerver.lib.timezone import get_all_timezones
|
||||
from zerver.lib.upload import upload_avatar_image
|
||||
from zerver.lib.validator import check_bool, check_int, check_int_in, check_string, check_string_in
|
||||
from zerver.models import UserProfile, avatar_changes_disabled, name_changes_disabled
|
||||
|
@ -158,7 +158,6 @@ def json_change_settings(request: HttpRequest, user_profile: UserProfile,
|
|||
|
||||
return json_success(result)
|
||||
|
||||
all_timezones = set(get_all_timezones())
|
||||
emojiset_choices = {emojiset['key'] for emojiset in UserProfile.emojiset_choices()}
|
||||
|
||||
@human_users_only
|
||||
|
@ -179,7 +178,7 @@ def update_display_settings_backend(
|
|||
emojiset_choices), default=None),
|
||||
demote_inactive_streams: Optional[int]=REQ(validator=check_int_in(
|
||||
UserProfile.DEMOTE_STREAMS_CHOICES), default=None),
|
||||
timezone: Optional[str]=REQ(validator=check_string_in(all_timezones),
|
||||
timezone: Optional[str]=REQ(validator=check_string_in(pytz.all_timezones_set),
|
||||
default=None)) -> HttpResponse:
|
||||
|
||||
# We can't use REQ for this widget because
|
||||
|
|
Loading…
Reference in New Issue