diff --git a/openedx/core/djangoapps/user_api/accounts/signals.py b/openedx/core/djangoapps/user_api/accounts/signals.py index a52abc68576e..a51a8160c93c 100644 --- a/openedx/core/djangoapps/user_api/accounts/signals.py +++ b/openedx/core/djangoapps/user_api/accounts/signals.py @@ -6,10 +6,13 @@ from django.dispatch import Signal # Signal to retire a user from LMS-initiated mailings (course mailings, etc) -USER_RETIRE_MAILINGS = Signal(providing_args=["user"]) +# providing_args=["user"] +USER_RETIRE_MAILINGS = Signal() # Signal to retire LMS critical information -USER_RETIRE_LMS_CRITICAL = Signal(providing_args=["user"]) +# providing_args=["user"] +USER_RETIRE_LMS_CRITICAL = Signal() # Signal to retire LMS misc information -USER_RETIRE_LMS_MISC = Signal(providing_args=["user"]) +# providing_args=["user"] +USER_RETIRE_LMS_MISC = Signal() diff --git a/openedx/core/djangoapps/user_api/accounts/utils.py b/openedx/core/djangoapps/user_api/accounts/utils.py index b78c19f2cb59..0cf44ef0684d 100644 --- a/openedx/core/djangoapps/user_api/accounts/utils.py +++ b/openedx/core/djangoapps/user_api/accounts/utils.py @@ -10,7 +10,7 @@ from completion.waffle import ENABLE_COMPLETION_TRACKING_SWITCH from completion.models import BlockCompletion from django.conf import settings -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from social_django.models import UserSocialAuth from common.djangoapps.student.models import AccountRecovery, Registration, get_retired_email_by_email diff --git a/openedx/core/djangoapps/user_api/accounts/views.py b/openedx/core/djangoapps/user_api/accounts/views.py index f5568dd76e35..1f6f26197f00 100644 --- a/openedx/core/djangoapps/user_api/accounts/views.py +++ b/openedx/core/djangoapps/user_api/accounts/views.py @@ -21,7 +21,7 @@ from django.contrib.sites.models import Site from django.core.cache import cache from django.db import models, transaction -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from edx_ace import ace from edx_ace.recipient import Recipient from edx_rest_framework_extensions.auth.jwt.authentication import JwtAuthentication diff --git a/openedx/core/djangoapps/user_api/admin.py b/openedx/core/djangoapps/user_api/admin.py index 9de740a0e359..aed5c658b9fb 100644 --- a/openedx/core/djangoapps/user_api/admin.py +++ b/openedx/core/djangoapps/user_api/admin.py @@ -10,7 +10,7 @@ from django.template.response import TemplateResponse from django.urls import reverse from django.utils.html import format_html -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from openedx.core.djangoapps.user_api.accounts.forms import RetirementQueueDeletionForm diff --git a/openedx/core/djangoapps/user_api/helpers.py b/openedx/core/djangoapps/user_api/helpers.py index 2c70e24eca88..7de43410a8a8 100644 --- a/openedx/core/djangoapps/user_api/helpers.py +++ b/openedx/core/djangoapps/user_api/helpers.py @@ -13,7 +13,7 @@ from django import forms from django.conf import settings from django.core.serializers.json import DjangoJSONEncoder -from django.utils.encoding import force_text +from django.utils.encoding import force_str from django.utils.functional import Promise LOGGER = logging.getLogger(__name__) @@ -357,7 +357,7 @@ def default(self, obj): # lint-amnesty, pylint: disable=arguments-differ Forces evaluation of ugettext_lazy promises. """ if isinstance(obj, Promise): - return force_text(obj) + return force_str(obj) super().default(obj) diff --git a/openedx/core/djangoapps/user_api/preferences/api.py b/openedx/core/djangoapps/user_api/preferences/api.py index ad63288ae32b..e0a6797ebe25 100644 --- a/openedx/core/djangoapps/user_api/preferences/api.py +++ b/openedx/core/djangoapps/user_api/preferences/api.py @@ -8,8 +8,8 @@ from django.conf import settings from django.core.exceptions import ObjectDoesNotExist from django.db import IntegrityError -from django.utils.translation import ugettext as _ -from django.utils.translation import ugettext_noop +from django.utils.translation import gettext as _ +from django.utils.translation import gettext_noop from django_countries import countries from pytz import common_timezones, common_timezones_set, country_timezones @@ -399,7 +399,7 @@ def validate_user_preference_serializer(serializer, preference_key, preference_v PreferenceValidationError: the supplied key and/or value for a user preference are invalid. """ if preference_value is None or str(preference_value).strip() == '': - format_string = ugettext_noop("Preference '{preference_key}' cannot be set to an empty value.") + format_string = gettext_noop("Preference '{preference_key}' cannot be set to an empty value.") raise PreferenceValidationError({ preference_key: { "developer_message": format_string.format(preference_key=preference_key), @@ -430,8 +430,8 @@ def validate_user_preference_serializer(serializer, preference_key, preference_v } }) if preference_key == "time_zone" and preference_value not in common_timezones_set: - developer_message = ugettext_noop("Value '{preference_value}' not valid for preference '{preference_key}': Not in timezone set.") # pylint: disable=line-too-long - user_message = ugettext_noop("Value '{preference_value}' is not a valid time zone selection.") + developer_message = gettext_noop("Value '{preference_value}' not valid for preference '{preference_key}': Not in timezone set.") # pylint: disable=line-too-long + user_message = gettext_noop("Value '{preference_value}' is not a valid time zone selection.") raise PreferenceValidationError({ preference_key: { "developer_message": developer_message.format( diff --git a/openedx/core/djangoapps/user_api/preferences/views.py b/openedx/core/djangoapps/user_api/preferences/views.py index 7fd78a1c4350..6f983a13afe2 100644 --- a/openedx/core/djangoapps/user_api/preferences/views.py +++ b/openedx/core/djangoapps/user_api/preferences/views.py @@ -7,7 +7,7 @@ from django.db import transaction -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from edx_rest_framework_extensions.auth.jwt.authentication import JwtAuthentication from edx_rest_framework_extensions.auth.session.authentication import SessionAuthenticationAllowInactiveUser from rest_framework import permissions, status diff --git a/openedx/core/djangoapps/user_authn/cookies.py b/openedx/core/djangoapps/user_authn/cookies.py index 0567f5d3be3b..2c85fac76e5e 100644 --- a/openedx/core/djangoapps/user_authn/cookies.py +++ b/openedx/core/djangoapps/user_authn/cookies.py @@ -28,8 +28,8 @@ log = logging.getLogger(__name__) - -CREATE_LOGON_COOKIE = Signal(providing_args=['user', 'response']) +# providing_args=['user', 'response'] +CREATE_LOGON_COOKIE = Signal() JWT_COOKIE_NAMES = ( diff --git a/openedx/core/djangoapps/user_authn/views/auto_auth.py b/openedx/core/djangoapps/user_authn/views/auto_auth.py index 7792f90d95bc..f385a30fe7f9 100644 --- a/openedx/core/djangoapps/user_authn/views/auto_auth.py +++ b/openedx/core/djangoapps/user_authn/views/auto_auth.py @@ -13,7 +13,7 @@ from django.shortcuts import redirect from django.template.context_processors import csrf from django.urls import NoReverseMatch, reverse -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from opaque_keys.edx.locator import CourseLocator from lms.djangoapps.verify_student.models import ManualVerification diff --git a/openedx/core/djangoapps/user_authn/views/login.py b/openedx/core/djangoapps/user_authn/views/login.py index ef02971e6be5..f061c5a65419 100644 --- a/openedx/core/djangoapps/user_authn/views/login.py +++ b/openedx/core/djangoapps/user_authn/views/login.py @@ -20,7 +20,7 @@ from django.shortcuts import redirect from django.urls import reverse from django.utils.decorators import method_decorator -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from django.views.decorators.csrf import csrf_exempt, csrf_protect, ensure_csrf_cookie from django.views.decorators.debug import sensitive_post_parameters from django.views.decorators.http import require_http_methods diff --git a/openedx/core/djangoapps/user_authn/views/login_form.py b/openedx/core/djangoapps/user_authn/views/login_form.py index 94c13ef95e9c..31b805b3cee0 100644 --- a/openedx/core/djangoapps/user_authn/views/login_form.py +++ b/openedx/core/djangoapps/user_authn/views/login_form.py @@ -9,7 +9,7 @@ from django.contrib import messages from django.shortcuts import redirect from django.urls import reverse -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from django.views.decorators.csrf import ensure_csrf_cookie from django.views.decorators.http import require_http_methods from ratelimit.decorators import ratelimit diff --git a/openedx/core/djangoapps/user_authn/views/password_reset.py b/openedx/core/djangoapps/user_authn/views/password_reset.py index 547535a233b9..764b4abea4cb 100644 --- a/openedx/core/djangoapps/user_authn/views/password_reset.py +++ b/openedx/core/djangoapps/user_authn/views/password_reset.py @@ -16,9 +16,9 @@ from django.template.response import TemplateResponse from django.urls import reverse from django.utils.decorators import method_decorator -from django.utils.encoding import force_bytes, force_text +from django.utils.encoding import force_bytes, force_str from django.utils.http import base36_to_int, int_to_base36, urlsafe_base64_encode -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from django.views.decorators.csrf import csrf_exempt, ensure_csrf_cookie from django.views.decorators.http import require_POST from edx_ace import ace @@ -338,7 +338,7 @@ def _uidb36_to_uidb64(uidb36): Returns: base64-encoded user ID. Otherwise returns a dummy, invalid ID """ try: - uidb64 = force_text(urlsafe_base64_encode(force_bytes(base36_to_int(uidb36)))) + uidb64 = force_str(urlsafe_base64_encode(force_bytes(base36_to_int(uidb36)))) except ValueError: uidb64 = '1' # dummy invalid ID (incorrect padding for base64) return uidb64 diff --git a/openedx/core/djangoapps/user_authn/views/register.py b/openedx/core/djangoapps/user_authn/views/register.py index 6cec0ae3bf21..98d9f1acc7f3 100644 --- a/openedx/core/djangoapps/user_authn/views/register.py +++ b/openedx/core/djangoapps/user_authn/views/register.py @@ -18,7 +18,7 @@ from django.urls import reverse from django.utils.decorators import method_decorator from django.utils.translation import get_language -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from django.views.decorators.csrf import csrf_exempt, ensure_csrf_cookie from django.views.decorators.debug import sensitive_post_parameters from edx_django_utils.monitoring import set_custom_attribute @@ -101,7 +101,8 @@ REGISTRATION_UTM_CREATED_AT = 'registration_utm_created_at' MARKETING_EMAILS_OPT_IN = 'marketing_emails_opt_in' # used to announce a registration -REGISTER_USER = Signal(providing_args=["user", "registration"]) +# providing_args=["user", "registration"] +REGISTER_USER = Signal() # .. toggle_name: registration.enable_failure_logging diff --git a/openedx/core/djangoapps/user_authn/views/registration_form.py b/openedx/core/djangoapps/user_authn/views/registration_form.py index 0a602c32b0cd..d530f493a9d2 100644 --- a/openedx/core/djangoapps/user_authn/views/registration_form.py +++ b/openedx/core/djangoapps/user_authn/views/registration_form.py @@ -13,7 +13,7 @@ from django.core.validators import RegexValidator, ValidationError, slug_re from django.forms import widgets from django.urls import reverse -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from django_countries import countries from common.djangoapps import third_party_auth diff --git a/openedx/core/djangoapps/user_authn/views/tests/test_logistration.py b/openedx/core/djangoapps/user_authn/views/tests/test_logistration.py index ec0f07e71187..87fd6ccb1707 100644 --- a/openedx/core/djangoapps/user_authn/views/tests/test_logistration.py +++ b/openedx/core/djangoapps/user_authn/views/tests/test_logistration.py @@ -17,7 +17,7 @@ from django.test.client import RequestFactory from django.test.utils import override_settings from django.urls import reverse -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from edx_toggles.toggles.testutils import override_waffle_flag from freezegun import freeze_time from pytz import UTC diff --git a/openedx/core/djangoapps/user_authn/views/utils.py b/openedx/core/djangoapps/user_authn/views/utils.py index b284fdde9d7a..c87718018f65 100644 --- a/openedx/core/djangoapps/user_authn/views/utils.py +++ b/openedx/core/djangoapps/user_authn/views/utils.py @@ -3,7 +3,7 @@ """ from django.conf import settings from django.contrib import messages -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from ipware.ip import get_client_ip from common.djangoapps import third_party_auth diff --git a/openedx/core/djangoapps/util/user_messages.py b/openedx/core/djangoapps/util/user_messages.py index e6438c58a3f1..2b6962f39f55 100644 --- a/openedx/core/djangoapps/util/user_messages.py +++ b/openedx/core/djangoapps/util/user_messages.py @@ -21,7 +21,7 @@ from django.conf import settings from django.contrib import messages -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from edx_toggles.toggles import SettingToggle from openedx.core.djangolib.markup import HTML, Text diff --git a/openedx/core/djangoapps/verified_track_content/forms.py b/openedx/core/djangoapps/verified_track_content/forms.py index 013b3d8502ac..16c104066794 100644 --- a/openedx/core/djangoapps/verified_track_content/forms.py +++ b/openedx/core/djangoapps/verified_track_content/forms.py @@ -4,7 +4,7 @@ from django import forms -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from opaque_keys import InvalidKeyError from opaque_keys.edx.keys import CourseKey diff --git a/openedx/core/djangoapps/verified_track_content/models.py b/openedx/core/djangoapps/verified_track_content/models.py index 39c64ea13818..3d1101fc6b46 100644 --- a/openedx/core/djangoapps/verified_track_content/models.py +++ b/openedx/core/djangoapps/verified_track_content/models.py @@ -10,7 +10,7 @@ from django.db.models.signals import post_save, pre_save from django.dispatch import receiver -from django.utils.translation import ugettext_lazy +from django.utils.translation import gettext_lazy from edx_django_utils.cache import RequestCache from opaque_keys.edx.django.models import CourseKeyField @@ -100,7 +100,7 @@ class VerifiedTrackCohortedCourse(models.Model): """ course_key = CourseKeyField( max_length=255, db_index=True, unique=True, - help_text=ugettext_lazy("The course key for the course we would like to be auto-cohorted.") + help_text=gettext_lazy("The course key for the course we would like to be auto-cohorted.") ) verified_cohort_name = models.CharField(max_length=100, default=DEFAULT_VERIFIED_COHORT_NAME) diff --git a/openedx/core/djangoapps/video_pipeline/models.py b/openedx/core/djangoapps/video_pipeline/models.py index cf1d575163f3..d58a958eb16a 100644 --- a/openedx/core/djangoapps/video_pipeline/models.py +++ b/openedx/core/djangoapps/video_pipeline/models.py @@ -6,7 +6,7 @@ from django.contrib.auth import get_user_model from django.db import models -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from opaque_keys.edx.django.models import CourseKeyField diff --git a/openedx/core/djangoapps/waffle_utils/models.py b/openedx/core/djangoapps/waffle_utils/models.py index 22dc021e872b..6e78e8106d2f 100644 --- a/openedx/core/djangoapps/waffle_utils/models.py +++ b/openedx/core/djangoapps/waffle_utils/models.py @@ -3,7 +3,7 @@ """ from django.db.models import CharField, TextField -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from model_utils import Choices from opaque_keys.edx.django.models import CourseKeyField diff --git a/openedx/core/djangoapps/xblock/api.py b/openedx/core/djangoapps/xblock/api.py index 9fde5ea29fde..60b8a1e13bbd 100644 --- a/openedx/core/djangoapps/xblock/api.py +++ b/openedx/core/djangoapps/xblock/api.py @@ -12,7 +12,7 @@ import threading from django.urls import reverse -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from opaque_keys.edx.keys import UsageKeyV2 from opaque_keys.edx.locator import BundleDefinitionLocator from rest_framework.exceptions import NotFound diff --git a/openedx/core/djangoapps/xblock/runtime/mixin.py b/openedx/core/djangoapps/xblock/runtime/mixin.py index 57eeb1d0dfbe..5e413ce5ebe5 100644 --- a/openedx/core/djangoapps/xblock/runtime/mixin.py +++ b/openedx/core/djangoapps/xblock/runtime/mixin.py @@ -4,7 +4,7 @@ """ -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from xblock.core import XBlock, XBlockMixin from xblock.exceptions import JsonHandlerError from web_fragments.fragment import Fragment diff --git a/openedx/core/djangolib/tests/test_markup.py b/openedx/core/djangolib/tests/test_markup.py index b23ffb97ce46..d3775deae652 100644 --- a/openedx/core/djangolib/tests/test_markup.py +++ b/openedx/core/djangolib/tests/test_markup.py @@ -7,8 +7,8 @@ import ddt from bs4 import BeautifulSoup -from django.utils.translation import ugettext as _ -from django.utils.translation import ungettext +from django.utils.translation import gettext as _ +from django.utils.translation import ngettext from mako.template import Template from openedx.core.djangolib.markup import HTML, Text, strip_all_tags_but_br @@ -66,7 +66,7 @@ def test_mako(self): def test_ungettext(self): for i in [1, 2]: - out = Text(ungettext("1 & {}", "2 & {}", i)).format(HTML("<>")) + out = Text(ngettext("1 & {}", "2 & {}", i)).format(HTML("<>")) assert out == f'{i} & <>' def test_strip_all_tags_but_br_filter(self): diff --git a/openedx/core/lib/api/view_utils.py b/openedx/core/lib/api/view_utils.py index 24ddc838874e..e9264697c14c 100644 --- a/openedx/core/lib/api/view_utils.py +++ b/openedx/core/lib/api/view_utils.py @@ -7,7 +7,7 @@ from django.core.exceptions import NON_FIELD_ERRORS, ObjectDoesNotExist, ValidationError from django.http import Http404, HttpResponseBadRequest -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from edx_rest_framework_extensions.auth.jwt.authentication import JwtAuthentication from edx_rest_framework_extensions.auth.session.authentication import SessionAuthenticationAllowInactiveUser from opaque_keys import InvalidKeyError diff --git a/openedx/core/lib/cache_utils.py b/openedx/core/lib/cache_utils.py index 52c58ec67780..387aaeaecce1 100644 --- a/openedx/core/lib/cache_utils.py +++ b/openedx/core/lib/cache_utils.py @@ -11,7 +11,7 @@ import wrapt from django.db.models.signals import post_save, post_delete -from django.utils.encoding import force_text +from django.utils.encoding import force_str from edx_django_utils.cache import RequestCache, TieredCache @@ -87,7 +87,7 @@ def _func_call_cache_key(func, arg_map_function, *args, **kwargs): the function's name, a stringified list of arguments and a stringified list of keyword arguments. """ - arg_map_function = arg_map_function or force_text + arg_map_function = arg_map_function or force_str converted_args = list(map(arg_map_function, args)) converted_kwargs = list(map(arg_map_function, _sorted_kwargs_list(kwargs))) diff --git a/openedx/core/lib/gating/api.py b/openedx/core/lib/gating/api.py index 313a326756f3..270a01457aa3 100644 --- a/openedx/core/lib/gating/api.py +++ b/openedx/core/lib/gating/api.py @@ -8,7 +8,7 @@ from completion.models import BlockCompletion from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user from django.urls import reverse -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from milestones import api as milestones_api from opaque_keys.edx.keys import UsageKey from xblock.completable import XBlockCompletionMode as CompletionMode