python: Convert deprecated Django ugettext alias to gettext.

django.utils.translation.ugettext is a deprecated alias of
django.utils.translation.gettext as of Django 3.0, and will be removed
in Django 4.0.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2021-04-15 15:57:30 -07:00 committed by Tim Abbott
parent 173ce9a3fc
commit e7ed907cf6
93 changed files with 150 additions and 150 deletions

View File

@ -23,7 +23,7 @@ from django.urls import reverse
from django.utils import translation
from django.utils.timesince import timesince
from django.utils.timezone import now as timezone_now
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
from jinja2 import Markup as mark_safe
from psycopg2.sql import SQL, Composable, Literal

View File

@ -13,9 +13,9 @@ from django.conf import settings
from django.core.signing import Signer
from django.db import transaction
from django.utils.timezone import now as timezone_now
from django.utils.translation import gettext as _
from django.utils.translation import gettext_lazy
from django.utils.translation import override as override_language
from django.utils.translation import ugettext as _
from django.utils.translation import ugettext_lazy
from corporate.models import (
Customer,
@ -172,8 +172,8 @@ def get_idempotency_key(ledger_entry: LicenseLedger) -> Optional[str]:
class BillingError(Exception):
# error messages
CONTACT_SUPPORT = ugettext_lazy("Something went wrong. Please contact {email}.")
TRY_RELOADING = ugettext_lazy("Something went wrong. Please reload the page.")
CONTACT_SUPPORT = gettext_lazy("Something went wrong. Please contact {email}.")
TRY_RELOADING = gettext_lazy("Something went wrong. Please reload the page.")
# description is used only for tests
def __init__(self, description: str, message: Optional[str] = None) -> None:

View File

@ -10,7 +10,7 @@ from django.http import HttpRequest, HttpResponse, HttpResponseRedirect
from django.shortcuts import render
from django.urls import reverse
from django.utils.timezone import now as timezone_now
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
from corporate.lib.stripe import (
DEFAULT_INVOICE_DAYS_UNTIL_DUE,

View File

@ -166,7 +166,7 @@ A string in Python can be marked for translation using the `_()` function,
which can be imported as follows:
```
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
```
Zulip expects all the error messages to be translatable as well. To
@ -180,13 +180,13 @@ JsonableError(_('English Text'))
```
If you're declaring a user-facing string at top level or in a class, you need to
use `ugettext_lazy` instead, to ensure that the translation happens at
use `gettext_lazy` instead, to ensure that the translation happens at
request-processing time when Django knows what language to use, e.g.:
```python
from zproject.backends import check_password_strength, email_belongs_to_ldap
AVATAR_CHANGES_DISABLED_ERROR = ugettext_lazy("Avatar changes are disabled in this organization.")
AVATAR_CHANGES_DISABLED_ERROR = gettext_lazy("Avatar changes are disabled in this organization.")
def confirm_email_change(request: HttpRequest, confirmation_key: str) -> HttpResponse:
...
@ -200,7 +200,7 @@ class Realm(models.Model):
...
...
STREAM_EVENTS_NOTIFICATION_TOPIC = ugettext_lazy('stream events')
STREAM_EVENTS_NOTIFICATION_TOPIC = gettext_lazy('stream events')
```
To ensure we always internationalize our JSON errors messages, the

View File

@ -84,7 +84,7 @@ The Hello World integration is in `zerver/webhooks/helloworld/view.py`:
from typing import Any, Dict, Iterable, Optional
from django.http import HttpRequest, HttpResponse
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
from zerver.decorator import webhook_view
from zerver.lib.webhooks.common import check_send_webhook_message

View File

@ -70,16 +70,16 @@ rules:
- id: translated-format
languages: [python]
pattern-either:
- pattern: django.utils.translation.ugettext(... .format(...))
- pattern: django.utils.translation.ugettext(f"...")
- pattern: django.utils.translation.ugettext_lazy(... .format(...))
- pattern: django.utils.translation.ugettext_lazy(f"...")
- pattern: django.utils.translation.gettext(... .format(...))
- pattern: django.utils.translation.gettext(f"...")
- pattern: django.utils.translation.gettext_lazy(... .format(...))
- pattern: django.utils.translation.gettext_lazy(f"...")
severity: ERROR
message: "Format strings after translation, not before"
- id: translated-format-lazy
languages: [python]
pattern: django.utils.translation.ugettext_lazy(...).format(...)
pattern: django.utils.translation.gettext_lazy(...).format(...)
severity: ERROR
message: "Immediately formatting a lazily translated string destroys its laziness"
@ -123,8 +123,8 @@ rules:
languages: [python]
pattern-either:
- pattern: '"..." % ...'
- pattern: django.utils.translation.ugettext(...) % ...
- pattern: django.utils.translation.ugettext_lazy(...) % ...
- pattern: django.utils.translation.gettext(...) % ...
- pattern: django.utils.translation.gettext_lazy(...) % ...
severity: ERROR
message: "Prefer f-strings or .format for string formatting"

View File

@ -18,7 +18,7 @@ from django.http.multipartparser import MultiPartParser
from django.shortcuts import resolve_url
from django.template.response import SimpleTemplateResponse, TemplateResponse
from django.utils.timezone import now as timezone_now
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
from django.views.decorators.csrf import csrf_exempt
from django_otp import user_has_device
from two_factor.utils import default_device

View File

@ -13,7 +13,7 @@ from django.core.validators import validate_email
from django.http import HttpRequest
from django.urls import reverse
from django.utils.http import urlsafe_base64_encode
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
from jinja2 import Markup as mark_safe
from two_factor.forms import AuthenticationTokenForm as TwoFactorAuthenticationTokenForm
from two_factor.utils import totp_digits

View File

@ -33,8 +33,8 @@ from django.db.models import Count, Exists, F, OuterRef, Q, Sum
from django.db.models.query import QuerySet
from django.utils.html import escape
from django.utils.timezone import now as timezone_now
from django.utils.translation import gettext as _
from django.utils.translation import override as override_language
from django.utils.translation import ugettext as _
from psycopg2.extras import execute_values
from psycopg2.sql import SQL
from typing_extensions import TypedDict

View File

@ -1,6 +1,6 @@
from typing import Iterable, List, Optional, Sequence, Union, cast
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
from zerver.lib.exceptions import JsonableError
from zerver.models import (

View File

@ -1,6 +1,6 @@
from typing import Any, Dict, List
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
from zerver.lib.request import JsonableError
from zerver.lib.upload import delete_message_image

View File

@ -4,7 +4,7 @@ import os
from typing import Any, Callable, Dict, Optional
from django.conf import settings
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
from zerver.lib.actions import (
internal_send_huddle_message,

View File

@ -2,7 +2,7 @@ import re
from typing import Optional
from django.core.exceptions import ValidationError
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
def validate_domain(domain: Optional[str]) -> None:

View File

@ -13,8 +13,8 @@ from bs4 import BeautifulSoup
from django.conf import settings
from django.contrib.auth import get_backends
from django.utils.timezone import now as timezone_now
from django.utils.translation import gettext as _
from django.utils.translation import override as override_language
from django.utils.translation import ugettext as _
from lxml.cssselect import CSSSelector
from confirmation.models import one_click_unsubscribe_link

View File

@ -2,7 +2,7 @@ from typing import Callable, Dict, Optional, Set, Tuple
from django.core import validators
from django.core.exceptions import ValidationError
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
from zerver.lib.name_restrictions import is_disposable_domain

View File

@ -3,7 +3,7 @@ import re
from typing import Optional, Tuple
import orjson
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
from zerver.lib.exceptions import OrganizationAdministratorRequired
from zerver.lib.request import JsonableError

View File

@ -5,7 +5,7 @@ from typing import Any, Dict
from django.conf import settings
from django.core.mail import mail_admins
from django.http import HttpResponse
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
from zerver.filters import clean_data_from_query_parameters
from zerver.lib.actions import internal_send_stream_message

View File

@ -4,7 +4,7 @@ import copy
from typing import Any, Callable, Dict, Iterable, Optional, Sequence, Set
from django.conf import settings
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
from version import API_FEATURE_LEVEL, ZULIP_VERSION
from zerver.lib.actions import (

View File

@ -1,7 +1,7 @@
from enum import Enum
from typing import Any, Dict, List, NoReturn, Optional, Type, TypeVar
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
T = TypeVar("T", bound="AbstractEnum")

View File

@ -2,7 +2,7 @@
This module stores data for "External Account" custom profile field.
"""
from django.core.exceptions import ValidationError
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
from zerver.lib.types import ProfileFieldData
from zerver.lib.validator import (

View File

@ -4,39 +4,39 @@ from typing import Dict, List
from django.conf import settings
from django.utils.functional import Promise
from django.utils.translation import ugettext_lazy
from django.utils.translation import gettext_lazy
from zerver.models import UserHotspot, UserProfile
INTRO_HOTSPOTS: Dict[str, Dict[str, Promise]] = {
"intro_reply": {
"title": ugettext_lazy("Reply to a message"),
"description": ugettext_lazy("Click anywhere on a message to reply."),
"title": gettext_lazy("Reply to a message"),
"description": gettext_lazy("Click anywhere on a message to reply."),
},
"intro_streams": {
"title": ugettext_lazy("Catch up on a stream"),
"description": ugettext_lazy(
"title": gettext_lazy("Catch up on a stream"),
"description": gettext_lazy(
"Messages sent to a stream are seen by everyone subscribed "
"to that stream. Try clicking on one of the stream links below."
),
},
"intro_topics": {
"title": ugettext_lazy("Topics"),
"description": ugettext_lazy(
"title": gettext_lazy("Topics"),
"description": gettext_lazy(
"Every message has a topic. Topics keep conversations "
"easy to follow, and make it easy to reply to conversations that start "
"while you are offline."
),
},
"intro_gear": {
"title": ugettext_lazy("Settings"),
"description": ugettext_lazy(
"title": gettext_lazy("Settings"),
"description": gettext_lazy(
"Go to Settings to configure your notifications and display settings."
),
},
"intro_compose": {
"title": ugettext_lazy("Compose"),
"description": ugettext_lazy(
"title": gettext_lazy("Compose"),
"description": gettext_lazy(
"Click here to start a new conversation. Pick a topic "
"(2-3 words is best), and give it a go!"
),

View File

@ -7,7 +7,7 @@ from django.contrib.staticfiles.storage import staticfiles_storage
from django.urls.resolvers import RegexPattern
from django.utils.functional import Promise
from django.utils.module_loading import import_string
from django.utils.translation import ugettext as ugettext_lazy
from django.utils.translation import gettext as gettext_lazy
from zerver.lib.storage import static_path
from zerver.lib.types import Validator
@ -32,20 +32,20 @@ features for writing and configuring integrations efficiently.
"""
CATEGORIES: Dict[str, Promise] = {
"meta-integration": ugettext_lazy("Integration frameworks"),
"continuous-integration": ugettext_lazy("Continuous integration"),
"customer-support": ugettext_lazy("Customer support"),
"deployment": ugettext_lazy("Deployment"),
"communication": ugettext_lazy("Communication"),
"financial": ugettext_lazy("Financial"),
"hr": ugettext_lazy("HR"),
"marketing": ugettext_lazy("Marketing"),
"misc": ugettext_lazy("Miscellaneous"),
"monitoring": ugettext_lazy("Monitoring tools"),
"project-management": ugettext_lazy("Project management"),
"productivity": ugettext_lazy("Productivity"),
"version-control": ugettext_lazy("Version control"),
"bots": ugettext_lazy("Interactive bots"),
"meta-integration": gettext_lazy("Integration frameworks"),
"continuous-integration": gettext_lazy("Continuous integration"),
"customer-support": gettext_lazy("Customer support"),
"deployment": gettext_lazy("Deployment"),
"communication": gettext_lazy("Communication"),
"financial": gettext_lazy("Financial"),
"hr": gettext_lazy("HR"),
"marketing": gettext_lazy("Marketing"),
"misc": gettext_lazy("Miscellaneous"),
"monitoring": gettext_lazy("Monitoring tools"),
"project-management": gettext_lazy("Project management"),
"productivity": gettext_lazy("Productivity"),
"version-control": gettext_lazy("Version control"),
"bots": gettext_lazy("Interactive bots"),
}

View File

@ -9,7 +9,7 @@ import orjson
from django.db import connection
from django.db.models import Max, Sum
from django.utils.timezone import now as timezone_now
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
from psycopg2.sql import SQL
from typing_extensions import TypedDict

View File

@ -2,7 +2,7 @@ import os
from typing import Any, Callable, Dict, Iterable, List, Mapping, Optional, Sequence
from django.conf import settings
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
from zerver.lib.request import JsonableError
from zerver.lib.topic import get_topic_from_message_info

View File

@ -2,7 +2,7 @@ from typing import Dict, List
from django.conf import settings
from django.db.models import Count
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
from zerver.lib.actions import (
create_users,

View File

@ -4,7 +4,7 @@ import logging
from typing import Any, AnyStr, Dict, Optional
import requests
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
from requests import Response, Session
from version import ZULIP_VERSION

View File

@ -13,7 +13,7 @@ from django.conf import settings
from django.db import IntegrityError, transaction
from django.db.models import F
from django.utils.timezone import now as timezone_now
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
from zerver.decorator import statsd_increment
from zerver.lib.avatar import absolute_avatar_url

View File

@ -6,7 +6,7 @@ import orjson
import requests
from django.conf import settings
from django.forms.models import model_to_dict
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
from analytics.models import InstallationCount, RealmCount
from version import ZULIP_VERSION

View File

@ -19,7 +19,7 @@ from typing import (
import orjson
from django.core.exceptions import ValidationError
from django.http import HttpRequest, HttpResponse
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
from typing_extensions import Literal
from zerver.lib.exceptions import ErrorCode, InvalidJSONError, JsonableError

View File

@ -2,7 +2,7 @@ from typing import Any, List, Mapping, Optional
import orjson
from django.http import HttpResponse, HttpResponseNotAllowed
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
from zerver.lib.exceptions import JsonableError

View File

@ -17,8 +17,8 @@ from django.db import transaction
from django.template import loader
from django.template.exceptions import TemplateDoesNotExist
from django.utils.timezone import now as timezone_now
from django.utils.translation import gettext as _
from django.utils.translation import override as override_language
from django.utils.translation import ugettext as _
from confirmation.models import generate_key
from scripts.setup.inline_email_css import inline_template

View File

@ -2,7 +2,7 @@ from typing import Iterable, List, Optional, Tuple, Union
from django.db.models.query import QuerySet
from django.utils.timezone import now as timezone_now
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
from typing_extensions import TypedDict
from zerver.lib.exceptions import StreamAdministratorRequired

View File

@ -23,7 +23,7 @@ from django.core.files import File
from django.core.signing import BadSignature, TimestampSigner
from django.http import HttpRequest
from django.urls import reverse
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
from jinja2 import Markup as mark_safe
from PIL import ExifTags, Image, ImageOps
from PIL.GifImagePlugin import GifImageFile

View File

@ -1,7 +1,7 @@
from typing import Any, Dict, List
from django.db import transaction
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
from zerver.lib.exceptions import JsonableError
from zerver.models import Realm, UserGroup, UserGroupMembership, UserProfile

View File

@ -7,7 +7,7 @@ from django.conf import settings
from django.core.exceptions import ValidationError
from django.db.models.query import QuerySet
from django.forms.models import model_to_dict
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
from zulip_bots.custom_exceptions import ConfigValidationError
from zerver.lib.avatar import avatar_url, get_avatar_field

View File

@ -34,7 +34,7 @@ from typing import Any, Callable, Dict, Iterable, List, Optional, Set, Tuple, Un
import orjson
from django.core.exceptions import ValidationError
from django.core.validators import URLValidator, validate_email
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
from zerver.lib.request import JsonableError, ResultT
from zerver.lib.types import ProfileFieldData, Validator

View File

@ -4,7 +4,7 @@ from typing import Any, Callable, Dict, Optional, Union
from urllib.parse import unquote
from django.http import HttpRequest
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
from zerver.lib.actions import (
check_send_private_message,

View File

@ -1,6 +1,6 @@
from typing import Any, Dict
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
from zerver.lib.actions import do_set_user_display_setting
from zerver.lib.exceptions import JsonableError

View File

@ -10,8 +10,8 @@ from django.conf import settings
from django.conf.locale import LANG_INFO
from django.core.management.base import CommandParser
from django.core.management.commands import compilemessages
from django.utils.translation import gettext as _
from django.utils.translation import override as override_language
from django.utils.translation import ugettext as _
from django.utils.translation.trans_real import to_language
from pyuca import Collator

View File

@ -15,7 +15,7 @@ from django.shortcuts import render
from django.utils import translation
from django.utils.cache import patch_vary_headers
from django.utils.deprecation import MiddlewareMixin
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
from django.views.csrf import csrf_failure as html_csrf_failure
from sentry_sdk import capture_exception
from sentry_sdk.integrations.logging import ignore_logger

View File

@ -32,8 +32,8 @@ from django.db.models.query import QuerySet
from django.db.models.signals import post_delete, post_save
from django.utils.functional import Promise
from django.utils.timezone import now as timezone_now
from django.utils.translation import ugettext as _
from django.utils.translation import ugettext_lazy
from django.utils.translation import gettext as _
from django.utils.translation import gettext_lazy
from confirmation import settings as confirmation_settings
from zerver.lib import cache
@ -363,7 +363,7 @@ class Realm(models.Model):
DEFAULT_NOTIFICATION_STREAM_NAME = "general"
INITIAL_PRIVATE_STREAM_NAME = "core team"
STREAM_EVENTS_NOTIFICATION_TOPIC = ugettext_lazy("stream events")
STREAM_EVENTS_NOTIFICATION_TOPIC = gettext_lazy("stream events")
notifications_stream: Optional["Stream"] = models.ForeignKey(
"Stream",
related_name="+",
@ -397,7 +397,7 @@ class Realm(models.Model):
COMMUNITY = 2
org_type: int = models.PositiveSmallIntegerField(default=CORPORATE)
UPGRADE_TEXT_STANDARD = ugettext_lazy("Available on Zulip Standard. Upgrade to access.")
UPGRADE_TEXT_STANDARD = gettext_lazy("Available on Zulip Standard. Upgrade to access.")
# plan_type controls various features around resource/feature
# limitations for a Zulip organization on multi-tenant installations
# like Zulip Cloud.
@ -815,7 +815,7 @@ class RealmEmoji(models.Model):
# ending with one of the punctuation characters.
RegexValidator(
regex=r"^[0-9a-z.\-_]+(?<![.\-_])$",
message=ugettext_lazy("Invalid characters in emoji name"),
message=gettext_lazy("Invalid characters in emoji name"),
),
]
)
@ -1387,10 +1387,10 @@ class UserProfile(AbstractBaseUser, PermissionsMixin):
)
ROLE_ID_TO_NAME_MAP = {
ROLE_REALM_OWNER: ugettext_lazy("Organization owner"),
ROLE_REALM_ADMINISTRATOR: ugettext_lazy("Organization administrator"),
ROLE_MEMBER: ugettext_lazy("Member"),
ROLE_GUEST: ugettext_lazy("Guest"),
ROLE_REALM_OWNER: gettext_lazy("Organization owner"),
ROLE_REALM_ADMINISTRATOR: gettext_lazy("Organization administrator"),
ROLE_MEMBER: gettext_lazy("Member"),
ROLE_GUEST: gettext_lazy("Guest"),
}
def get_role_name(self) -> str:
@ -2338,9 +2338,9 @@ class AbstractReaction(models.Model):
REALM_EMOJI = "realm_emoji"
ZULIP_EXTRA_EMOJI = "zulip_extra_emoji"
REACTION_TYPES = (
(UNICODE_EMOJI, ugettext_lazy("Unicode emoji")),
(REALM_EMOJI, ugettext_lazy("Custom emoji")),
(ZULIP_EXTRA_EMOJI, ugettext_lazy("Zulip extra emoji")),
(UNICODE_EMOJI, gettext_lazy("Unicode emoji")),
(REALM_EMOJI, gettext_lazy("Custom emoji")),
(ZULIP_EXTRA_EMOJI, gettext_lazy("Zulip extra emoji")),
)
reaction_type: str = models.CharField(
default=UNICODE_EMOJI, choices=REACTION_TYPES, max_length=30
@ -3457,10 +3457,10 @@ class CustomProfileField(models.Model):
# and value argument. i.e. SELECT require field_data, USER require
# realm as argument.
SELECT_FIELD_TYPE_DATA: List[ExtendedFieldElement] = [
(SELECT, ugettext_lazy("List of options"), validate_select_field, str, "SELECT"),
(SELECT, gettext_lazy("List of options"), validate_select_field, str, "SELECT"),
]
USER_FIELD_TYPE_DATA: List[UserFieldElement] = [
(USER, ugettext_lazy("Person picker"), check_valid_user_ids, ast.literal_eval, "USER"),
(USER, gettext_lazy("Person picker"), check_valid_user_ids, ast.literal_eval, "USER"),
]
SELECT_FIELD_VALIDATORS: Dict[int, ExtendedValidator] = {
@ -3472,13 +3472,13 @@ class CustomProfileField(models.Model):
FIELD_TYPE_DATA: List[FieldElement] = [
# Type, Display Name, Validator, Converter, Keyword
(SHORT_TEXT, ugettext_lazy("Short text"), check_short_string, str, "SHORT_TEXT"),
(LONG_TEXT, ugettext_lazy("Long text"), check_long_string, str, "LONG_TEXT"),
(DATE, ugettext_lazy("Date picker"), check_date, str, "DATE"),
(URL, ugettext_lazy("Link"), check_url, str, "URL"),
(SHORT_TEXT, gettext_lazy("Short text"), check_short_string, str, "SHORT_TEXT"),
(LONG_TEXT, gettext_lazy("Long text"), check_long_string, str, "LONG_TEXT"),
(DATE, gettext_lazy("Date picker"), check_date, str, "DATE"),
(URL, gettext_lazy("Link"), check_url, str, "URL"),
(
EXTERNAL_ACCOUNT,
ugettext_lazy("External account"),
gettext_lazy("External account"),
check_short_string,
str,
"EXTERNAL_ACCOUNT",

View File

@ -6,7 +6,7 @@ from django.contrib.auth.signals import user_logged_in, user_logged_out
from django.dispatch import receiver
from django.utils.timezone import get_current_timezone_name as timezone_get_current_timezone_name
from django.utils.timezone import now as timezone_now
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
from confirmation.models import one_click_unsubscribe_link
from zerver.lib.actions import do_set_zoom_token

View File

@ -30,7 +30,7 @@ from typing import (
import orjson
import tornado.ioloop
from django.conf import settings
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
from typing_extensions import TypedDict
from zerver.decorator import cachify

View File

@ -1,4 +1,4 @@
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
from zerver.lib.exceptions import ErrorCode, JsonableError

View File

@ -3,7 +3,7 @@ from typing import Iterable, Optional, Sequence
import orjson
from django.http import HttpRequest, HttpResponse
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
from zerver.decorator import REQ, has_request_variables, internal_notify_view, process_client
from zerver.lib.response import json_error, json_success

View File

@ -17,7 +17,7 @@ from django.shortcuts import redirect, render
from django.template.response import SimpleTemplateResponse
from django.urls import reverse
from django.utils.http import is_safe_url
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
from django.views.decorators.csrf import csrf_exempt
from django.views.decorators.http import require_safe
from social_django.utils import load_backend, load_strategy

View File

@ -1,7 +1,7 @@
from django.conf import settings
from django.http import HttpRequest, HttpResponse, HttpResponseForbidden, HttpResponseNotFound
from django.shortcuts import redirect
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
from zerver.lib.camo import is_camo_url_valid
from zerver.lib.thumbnail import generate_thumbnail_url

View File

@ -2,7 +2,7 @@ import re
from typing import List, Optional, Tuple
from django.http import HttpRequest, HttpResponse
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
from version import DESKTOP_MINIMUM_VERSION, DESKTOP_WARNING_VERSION
from zerver.lib.response import json_error, json_success

View File

@ -4,7 +4,7 @@ import orjson
from django.core.exceptions import ValidationError
from django.db import IntegrityError
from django.http import HttpRequest, HttpResponse
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
from zerver.decorator import human_users_only, require_realm_admin
from zerver.lib.actions import (

View File

@ -3,7 +3,7 @@ from typing import Any, Dict, List, Set
from django.core.exceptions import ValidationError
from django.http import HttpRequest, HttpResponse
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
from zerver.lib.actions import recipient_for_user_profiles
from zerver.lib.addressee import get_user_profiles_by_ids

View File

@ -1,7 +1,7 @@
from typing import Dict, Iterable, Optional, Sequence
from django.http import HttpRequest, HttpResponse
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
from zerver.lib.events import do_events_register
from zerver.lib.request import REQ, has_request_variables

View File

@ -1,5 +1,5 @@
from django.http import HttpRequest, HttpResponse
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
from zerver.decorator import human_users_only
from zerver.lib.actions import do_mark_hotspot_as_read

View File

@ -2,7 +2,7 @@ import re
from typing import List, Sequence, Set
from django.http import HttpRequest, HttpResponse
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
from zerver.decorator import require_member_or_admin, require_realm_admin
from zerver.lib.actions import (

View File

@ -5,7 +5,7 @@ import orjson
from django.db import IntegrityError
from django.http import HttpRequest, HttpResponse
from django.utils.timezone import now as timezone_now
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
from zerver.decorator import REQ, has_request_variables
from zerver.lib.actions import (

View File

@ -8,7 +8,7 @@ from django.core.exceptions import ValidationError
from django.db import connection
from django.http import HttpRequest, HttpResponse
from django.utils.html import escape as escape_html
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
from sqlalchemy import func
from sqlalchemy.dialects import postgresql
from sqlalchemy.engine import Connection, RowProxy

View File

@ -1,7 +1,7 @@
from typing import List, Optional
from django.http import HttpRequest, HttpResponse
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
from zerver.decorator import REQ, has_request_variables
from zerver.lib.actions import (

View File

@ -6,7 +6,7 @@ from django.core import validators
from django.core.exceptions import ValidationError
from django.http import HttpRequest, HttpResponse
from django.utils.timezone import now as timezone_now
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
from zerver.decorator import REQ, has_request_variables
from zerver.lib.actions import (

View File

@ -3,7 +3,7 @@ from typing import Optional
from django.http import HttpRequest, HttpResponse
from django.utils.timezone import now as timezone_now
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
from zerver.lib.actions import do_mute_topic, do_mute_user, do_unmute_topic, do_unmute_user
from zerver.lib.request import REQ, has_request_variables

View File

@ -4,7 +4,7 @@ from typing import Any, Dict, Optional
from django.conf import settings
from django.http import HttpRequest, HttpResponse
from django.utils.timezone import now as timezone_now
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
from zerver.decorator import human_users_only
from zerver.lib.actions import do_update_user_status, update_user_presence

View File

@ -1,6 +1,6 @@
from django.conf import settings
from django.http import HttpRequest, HttpResponse
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
from zerver.decorator import human_users_only
from zerver.lib.push_notifications import (

View File

@ -1,7 +1,7 @@
from typing import Optional
from django.http import HttpRequest, HttpResponse
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
from zerver.decorator import REQ, has_request_variables
from zerver.lib.actions import do_add_reaction, do_remove_reaction

View File

@ -3,7 +3,7 @@ from typing import Any, Dict, Optional, Union
from django.core.exceptions import ValidationError
from django.http import HttpRequest, HttpResponse
from django.shortcuts import render
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
from django.views.decorators.http import require_safe
from confirmation.models import Confirmation, ConfirmationKeyException, get_object_from_key

View File

@ -1,6 +1,6 @@
from django.core.exceptions import ValidationError
from django.http import HttpRequest, HttpResponse
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
from zerver.decorator import require_realm_admin
from zerver.lib.actions import do_add_realm_domain, do_change_realm_domain, do_remove_realm_domain

View File

@ -1,6 +1,6 @@
from django.conf import settings
from django.http import HttpRequest, HttpResponse
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
from zerver.decorator import require_member_or_admin
from zerver.lib.actions import check_add_realm_emoji, do_remove_realm_emoji

View File

@ -4,7 +4,7 @@ import orjson
from django.conf import settings
from django.http import HttpRequest, HttpResponse
from django.utils.timezone import now as timezone_now
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
from analytics.models import RealmCount
from zerver.decorator import require_realm_admin

View File

@ -1,7 +1,7 @@
from django.conf import settings
from django.http import HttpRequest, HttpResponse
from django.shortcuts import redirect
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
from zerver.decorator import require_realm_admin
from zerver.lib.actions import do_change_icon_source

View File

@ -1,6 +1,6 @@
from django.core.exceptions import ValidationError
from django.http import HttpRequest, HttpResponse
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
from zerver.decorator import require_realm_admin
from zerver.lib.actions import do_add_linkifier, do_remove_linkifier

View File

@ -1,7 +1,7 @@
from django.conf import settings
from django.http import HttpRequest, HttpResponse
from django.shortcuts import redirect
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
from zerver.decorator import require_realm_admin
from zerver.lib.actions import do_change_logo_source

View File

@ -2,7 +2,7 @@ import re
from django.core.exceptions import ValidationError
from django.http import HttpRequest, HttpResponse
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
from zerver.decorator import require_realm_admin
from zerver.lib.actions import do_add_realm_playground, do_remove_realm_playground

View File

@ -13,7 +13,7 @@ from django.db.models import Q
from django.http import HttpRequest, HttpResponse, HttpResponseRedirect
from django.shortcuts import redirect, render
from django.urls import reverse
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
from django_auth_ldap.backend import LDAPBackend, _LDAPUser
from confirmation import settings as confirmation_settings

View File

@ -7,8 +7,8 @@ from django.contrib.auth.models import AnonymousUser
from django.core.exceptions import ValidationError
from django.db import transaction
from django.http import HttpRequest, HttpResponse
from django.utils.translation import gettext as _
from django.utils.translation import override as override_language
from django.utils.translation import ugettext as _
from zerver.context_processors import get_valid_realm_from_request
from zerver.decorator import (

View File

@ -1,6 +1,6 @@
import orjson
from django.http import HttpRequest, HttpResponse
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
from zerver.decorator import REQ, has_request_variables
from zerver.lib.actions import do_add_submessage

View File

@ -3,7 +3,7 @@ from typing import Optional
from django.http import HttpRequest, HttpResponse, HttpResponseForbidden
from django.shortcuts import redirect
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
from zerver.lib.request import REQ, has_request_variables
from zerver.lib.thumbnail import generate_thumbnail_url

View File

@ -1,7 +1,7 @@
from typing import List
from django.http import HttpRequest, HttpResponse
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
from zerver.decorator import REQ, has_request_variables
from zerver.lib.actions import check_send_typing_notification

View File

@ -4,7 +4,7 @@ from django.conf import settings
from django.http import HttpRequest, HttpResponse, HttpResponseForbidden, HttpResponseNotFound
from django.shortcuts import redirect
from django.utils.cache import patch_cache_control
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
from django_sendfile import sendfile
from zerver.lib.response import json_error, json_success

View File

@ -1,7 +1,7 @@
from typing import Sequence
from django.http import HttpRequest, HttpResponse
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
from zerver.decorator import require_member_or_admin, require_user_group_edit_permission
from zerver.lib.actions import (

View File

@ -8,8 +8,8 @@ from django.http import HttpRequest, HttpResponse
from django.shortcuts import render
from django.utils.html import escape
from django.utils.safestring import SafeString
from django.utils.translation import ugettext as _
from django.utils.translation import ugettext_lazy
from django.utils.translation import gettext as _
from django.utils.translation import gettext_lazy
from confirmation.models import (
Confirmation,
@ -46,7 +46,7 @@ from zerver.lib.validator import check_bool, check_int, check_int_in, check_stri
from zerver.models import UserProfile, avatar_changes_disabled, name_changes_disabled
from zproject.backends import check_password_strength, email_belongs_to_ldap
AVATAR_CHANGES_DISABLED_ERROR = ugettext_lazy("Avatar changes are disabled in this organization.")
AVATAR_CHANGES_DISABLED_ERROR = gettext_lazy("Avatar changes are disabled in this organization.")
def confirm_email_change(request: HttpRequest, confirmation_key: str) -> HttpResponse:

View File

@ -3,7 +3,7 @@ from typing import Any, Dict, List, Optional, Union
from django.conf import settings
from django.http import HttpRequest, HttpResponse
from django.shortcuts import redirect
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
from zerver.decorator import require_member_or_admin, require_realm_admin
from zerver.forms import PASSWORD_TOO_WEAK_ERROR, CreateUserForm

View File

@ -14,7 +14,7 @@ from django.http import HttpRequest, HttpResponse
from django.middleware import csrf
from django.shortcuts import redirect, render
from django.utils.crypto import constant_time_compare, salted_hmac
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
from django.views.decorators.cache import never_cache
from django.views.decorators.csrf import csrf_exempt
from django.views.decorators.http import require_POST

View File

@ -8,7 +8,7 @@ from typing import Optional
import orjson
from django.conf import settings
from django.http import HttpRequest, HttpResponse
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
from zerver.decorator import authenticated_json_view
from zerver.lib.ccache import make_ccache

View File

@ -1,7 +1,7 @@
from typing import Any, Dict, Tuple
from django.http import HttpRequest, HttpResponse
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
from zerver.decorator import webhook_view
from zerver.lib.request import REQ, has_request_variables

View File

@ -1,7 +1,7 @@
from typing import Any, Dict
from django.http import HttpRequest, HttpResponse
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
from zerver.decorator import webhook_view
from zerver.lib.request import REQ, has_request_variables

View File

@ -3,7 +3,7 @@ from typing import Any, Callable, Dict, List, Tuple
import orjson
from django.http import HttpRequest, HttpResponse
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
from zerver.decorator import webhook_view
from zerver.lib.request import REQ, has_request_variables

View File

@ -2,7 +2,7 @@
from typing import Any, Dict
from django.http import HttpRequest, HttpResponse
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
from zerver.decorator import webhook_view
from zerver.lib.request import REQ, has_request_variables

View File

@ -5,7 +5,7 @@ from typing import Any, Dict, List, Optional, Tuple
import orjson
from defusedxml.ElementTree import fromstring as xml_fromstring
from django.http import HttpRequest, HttpResponse
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
from zerver.decorator import webhook_view
from zerver.lib.exceptions import UnsupportedWebhookEventType

View File

@ -1,5 +1,5 @@
from django.http import HttpRequest
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
from zerver.decorator import webhook_view
from zerver.lib.actions import check_send_stream_message

View File

@ -4,7 +4,7 @@ from typing import Any, Dict, Optional
import orjson
from django.http import HttpRequest, HttpResponse
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
from zerver.decorator import webhook_view
from zerver.lib.exceptions import InvalidJSONError

View File

@ -1,6 +1,6 @@
# Webhooks for external integrations.
from django.http import HttpRequest, HttpResponse
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
from zerver.decorator import webhook_view
from zerver.lib.request import REQ, has_request_variables

View File

@ -1,7 +1,7 @@
from typing import Any, Dict
from django.http import HttpRequest, HttpResponse
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
from zerver.decorator import REQ, has_request_variables, webhook_view
from zerver.lib.actions import send_rate_limited_pm_notification_to_bot_owner

View File

@ -1,7 +1,7 @@
from typing import Any, Dict
from django.http import HttpRequest, HttpResponse
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
from zerver.decorator import webhook_view
from zerver.lib.request import REQ, has_request_variables

View File

@ -40,8 +40,8 @@ from django.conf import settings
from django.db import connection
from django.db.models import F
from django.utils.timezone import now as timezone_now
from django.utils.translation import gettext as _
from django.utils.translation import override as override_language
from django.utils.translation import ugettext as _
from sentry_sdk import add_breadcrumb, configure_scope
from zulip_bots.lib import extract_query_without_mention

View File

@ -7,8 +7,8 @@ from django.core.validators import URLValidator, validate_email
from django.db import IntegrityError, transaction
from django.http import HttpRequest, HttpResponse
from django.utils import timezone
from django.utils.translation import ugettext as _
from django.utils.translation import ugettext as err_
from django.utils.translation import gettext as _
from django.utils.translation import gettext as err_
from django.views.decorators.csrf import csrf_exempt
from analytics.lib.counts import COUNT_STATS

View File

@ -30,7 +30,7 @@ from django.dispatch import Signal, receiver
from django.http import HttpRequest, HttpResponse, HttpResponseRedirect
from django.shortcuts import render
from django.urls import reverse
from django.utils.translation import ugettext as _
from django.utils.translation import gettext as _
from django_auth_ldap.backend import LDAPBackend, LDAPReverseEmailSearch, _LDAPUser, ldap_error
from lxml.etree import XMLSyntaxError
from onelogin.saml2.errors import OneLogin_Saml2_Error