feat: django codemods changes for common folder (#28775)
This commit is contained in:
@@ -5,7 +5,7 @@ from django import forms
|
||||
from django.conf import settings
|
||||
from django.contrib import admin
|
||||
from django.http.request import QueryDict
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from opaque_keys.edx.keys import CourseKey
|
||||
from pytz import UTC, timezone
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
import logging
|
||||
from django.conf import settings
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from urllib.parse import urljoin
|
||||
|
||||
from requests.exceptions import ConnectionError, Timeout # pylint: disable=redefined-builtin
|
||||
|
||||
@@ -15,7 +15,7 @@ from django.db.models import Q
|
||||
from django.dispatch import receiver
|
||||
|
||||
from django.utils.timezone import now
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from edx_django_utils.cache import RequestCache
|
||||
from opaque_keys.edx.django.models import CourseKeyField
|
||||
from simple_history.models import HistoricalRecords
|
||||
|
||||
@@ -18,7 +18,7 @@ from django.shortcuts import redirect
|
||||
from django.urls import reverse
|
||||
from django.utils.decorators import method_decorator
|
||||
from django.utils.translation import get_language, to_locale
|
||||
from django.utils.translation import ugettext as _
|
||||
from django.utils.translation import gettext as _
|
||||
from django.views.generic.base import View
|
||||
from edx_django_utils.monitoring.utils import increment
|
||||
from ipware.ip import get_client_ip
|
||||
|
||||
@@ -4,12 +4,11 @@
|
||||
import re
|
||||
from io import BytesIO
|
||||
from unittest.mock import Mock, patch
|
||||
from urllib.parse import parse_qsl, urlparse, urlunparse
|
||||
from urllib.parse import parse_qsl, quote, urlparse, urlunparse, urlencode
|
||||
|
||||
import ddt
|
||||
import pytest
|
||||
from django.test import override_settings
|
||||
from django.utils.http import urlencode, urlquote
|
||||
from opaque_keys.edx.keys import CourseKey
|
||||
from PIL import Image
|
||||
|
||||
@@ -45,9 +44,9 @@ def encode_unicode_characters_in_url(url):
|
||||
query_params = parse_qsl(query)
|
||||
updated_query_params = []
|
||||
for query_name, query_val in query_params:
|
||||
updated_query_params.append((query_name, urlquote(query_val)))
|
||||
updated_query_params.append((query_name, quote(query_val)))
|
||||
|
||||
return urlunparse((scheme, netloc, urlquote(path, '/:+@'), params, urlencode(query_params), fragment))
|
||||
return urlunparse((scheme, netloc, quote(path, '/:+@'), params, urlencode(query_params), fragment))
|
||||
|
||||
|
||||
def test_multi_replace():
|
||||
@@ -60,7 +59,7 @@ def test_multi_replace():
|
||||
|
||||
|
||||
def test_process_url():
|
||||
def processor(__, prefix, quote, rest):
|
||||
def processor(__, prefix, quote, rest): # pylint: disable=redefined-outer-name
|
||||
return quote + 'test' + prefix + rest + quote
|
||||
|
||||
assert process_static_urls(STATIC_SOURCE, processor) == '"test/static/file.png"'
|
||||
@@ -69,7 +68,7 @@ def test_process_url():
|
||||
def test_process_url_data_dir_exists():
|
||||
base = f'"/static/{DATA_DIRECTORY}/file.png"'
|
||||
|
||||
def processor(original, prefix, quote, rest): # pylint: disable=unused-argument
|
||||
def processor(original, prefix, quote, rest): # pylint: disable=unused-argument, redefined-outer-name
|
||||
return quote + 'test' + rest + quote
|
||||
|
||||
assert process_static_urls(base, processor, data_dir=DATA_DIRECTORY) == base
|
||||
@@ -77,7 +76,7 @@ def test_process_url_data_dir_exists():
|
||||
|
||||
def test_process_url_no_match():
|
||||
|
||||
def processor(__, prefix, quote, rest):
|
||||
def processor(__, prefix, quote, rest): # pylint: disable=redefined-outer-name
|
||||
return quote + 'test' + prefix + rest + quote
|
||||
|
||||
assert process_static_urls(STATIC_SOURCE, processor) == '"test/static/file.png"'
|
||||
@@ -534,11 +533,11 @@ class CanonicalContentTest(SharedModuleStoreTestCase):
|
||||
def test_canonical_asset_path_with_new_style_assets(self, base_url, start, expected, mongo_calls):
|
||||
exts = ['.html', '.tm']
|
||||
prefix = 'split'
|
||||
encoded_base_url = urlquote('//' + base_url)
|
||||
encoded_base_url = quote('//' + base_url)
|
||||
c4x = 'c4x/a/b/asset'
|
||||
base_asset_key = f'asset-v1:a+b+{prefix}+type@asset+block'
|
||||
adjusted_asset_key = base_asset_key
|
||||
encoded_asset_key = urlquote(f'/asset-v1:a+b+{prefix}+type@asset+block@')
|
||||
encoded_asset_key = quote(f'/asset-v1:a+b+{prefix}+type@asset+block@')
|
||||
encoded_base_asset_key = encoded_asset_key
|
||||
base_th_key = f'asset-v1:a+b+{prefix}+type@thumbnail+block'
|
||||
adjusted_th_key = base_th_key
|
||||
@@ -565,7 +564,7 @@ class CanonicalContentTest(SharedModuleStoreTestCase):
|
||||
adjusted_asset_key = f'assets/courseware/VMARK/HMARK/asset-v1:a+b+{prefix}+type@asset+block'
|
||||
adjusted_th_key = f'assets/courseware/VMARK/HMARK/asset-v1:a+b+{prefix}+type@thumbnail+block'
|
||||
encoded_asset_key = f'/assets/courseware/VMARK/HMARK/asset-v1:a+b+{prefix}+type@asset+block@'
|
||||
encoded_asset_key = urlquote(encoded_asset_key)
|
||||
encoded_asset_key = quote(encoded_asset_key)
|
||||
|
||||
expected = expected.format(
|
||||
prfx=prefix,
|
||||
@@ -747,8 +746,8 @@ class CanonicalContentTest(SharedModuleStoreTestCase):
|
||||
prefix = 'old'
|
||||
base_c4x_block = 'c4x/a/b/asset'
|
||||
adjusted_c4x_block = base_c4x_block
|
||||
encoded_c4x_block = urlquote('/' + base_c4x_block + '/')
|
||||
encoded_base_url = urlquote('//' + base_url)
|
||||
encoded_c4x_block = quote('/' + base_c4x_block + '/')
|
||||
encoded_base_url = quote('//' + base_url)
|
||||
encoded_base_c4x_block = encoded_c4x_block
|
||||
|
||||
start = start.format(
|
||||
@@ -765,7 +764,7 @@ class CanonicalContentTest(SharedModuleStoreTestCase):
|
||||
digest = CanonicalContentTest.get_content_digest_for_asset_path(prefix, start)
|
||||
if digest:
|
||||
adjusted_c4x_block = 'assets/courseware/VMARK/HMARK/c4x/a/b/asset'
|
||||
encoded_c4x_block = urlquote('/' + adjusted_c4x_block + '/')
|
||||
encoded_c4x_block = quote('/' + adjusted_c4x_block + '/')
|
||||
|
||||
expected = expected.format(
|
||||
prfx=prefix,
|
||||
|
||||
@@ -18,7 +18,7 @@ from django.http import HttpResponseRedirect
|
||||
from django.http.request import QueryDict
|
||||
from django.urls import reverse
|
||||
from django.utils.translation import ngettext
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from opaque_keys import InvalidKeyError
|
||||
from opaque_keys.edx.keys import CourseKey
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ from django.core.exceptions import ObjectDoesNotExist, PermissionDenied
|
||||
from django.core.validators import ValidationError
|
||||
from django.db import IntegrityError, ProgrammingError, transaction
|
||||
from django.urls import NoReverseMatch, reverse
|
||||
from django.utils.translation import ugettext as _
|
||||
from django.utils.translation import gettext as _
|
||||
from pytz import UTC
|
||||
|
||||
from common.djangoapps import third_party_auth
|
||||
|
||||
@@ -7,7 +7,7 @@ disabled accounts from accessing the site.
|
||||
from django.conf import settings
|
||||
from django.http import HttpResponseForbidden
|
||||
from django.utils.deprecation import MiddlewareMixin
|
||||
from django.utils.translation import ugettext as _
|
||||
from django.utils.translation import gettext as _
|
||||
|
||||
from openedx.core.djangolib.markup import HTML, Text
|
||||
from common.djangoapps.student.models import UserStanding
|
||||
|
||||
@@ -40,8 +40,8 @@ from django.db.utils import ProgrammingError
|
||||
from django.dispatch import receiver
|
||||
|
||||
from django.utils.functional import cached_property
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import ugettext_noop
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.utils.translation import gettext_noop
|
||||
from django_countries.fields import CountryField
|
||||
from edx_django_utils.cache import RequestCache, TieredCache, get_cache_key
|
||||
from edx_django_utils import monitoring
|
||||
@@ -528,10 +528,10 @@ class UserProfile(models.Model):
|
||||
VALID_YEARS = list(range(this_year, this_year - 120, -1))
|
||||
year_of_birth = models.IntegerField(blank=True, null=True, db_index=True)
|
||||
GENDER_CHOICES = (
|
||||
('m', ugettext_noop('Male')),
|
||||
('f', ugettext_noop('Female')),
|
||||
('m', gettext_noop('Male')),
|
||||
('f', gettext_noop('Female')),
|
||||
# Translators: 'Other' refers to the student's gender
|
||||
('o', ugettext_noop('Other/Prefer Not to Say'))
|
||||
('o', gettext_noop('Other/Prefer Not to Say'))
|
||||
)
|
||||
gender = models.CharField(
|
||||
blank=True, null=True, max_length=6, db_index=True, choices=GENDER_CHOICES
|
||||
@@ -542,17 +542,17 @@ class UserProfile(models.Model):
|
||||
# ('p_se', 'Doctorate in science or engineering'),
|
||||
# ('p_oth', 'Doctorate in another field'),
|
||||
LEVEL_OF_EDUCATION_CHOICES = (
|
||||
('p', ugettext_noop('Doctorate')),
|
||||
('m', ugettext_noop("Master's or professional degree")),
|
||||
('b', ugettext_noop("Bachelor's degree")),
|
||||
('a', ugettext_noop("Associate degree")),
|
||||
('hs', ugettext_noop("Secondary/high school")),
|
||||
('jhs', ugettext_noop("Junior secondary/junior high/middle school")),
|
||||
('el', ugettext_noop("Elementary/primary school")),
|
||||
('p', gettext_noop('Doctorate')),
|
||||
('m', gettext_noop("Master's or professional degree")),
|
||||
('b', gettext_noop("Bachelor's degree")),
|
||||
('a', gettext_noop("Associate degree")),
|
||||
('hs', gettext_noop("Secondary/high school")),
|
||||
('jhs', gettext_noop("Junior secondary/junior high/middle school")),
|
||||
('el', gettext_noop("Elementary/primary school")),
|
||||
# Translators: 'None' refers to the student's level of education
|
||||
('none', ugettext_noop("No formal education")),
|
||||
('none', gettext_noop("No formal education")),
|
||||
# Translators: 'Other' refers to the student's level of education
|
||||
('other', ugettext_noop("Other education"))
|
||||
('other', gettext_noop("Other education"))
|
||||
)
|
||||
level_of_education = models.CharField(
|
||||
blank=True, null=True, max_length=6, db_index=True,
|
||||
|
||||
@@ -5,7 +5,17 @@ Enrollment track related signals.
|
||||
|
||||
from django.dispatch import Signal
|
||||
|
||||
ENROLLMENT_TRACK_UPDATED = Signal(providing_args=['user', 'course_key', 'mode', 'countdown'])
|
||||
UNENROLL_DONE = Signal(providing_args=["course_enrollment", "skip_refund"])
|
||||
ENROLL_STATUS_CHANGE = Signal(providing_args=["event", "user", "course_id", "mode", "cost", "currency"])
|
||||
REFUND_ORDER = Signal(providing_args=["course_enrollment"])
|
||||
# The purely documentational providing_args argument for Signal is deprecated.
|
||||
# So we are moving the args to a comment.
|
||||
|
||||
# providing_args=['user', 'course_key', 'mode', 'countdown']
|
||||
ENROLLMENT_TRACK_UPDATED = Signal()
|
||||
|
||||
# providing_args=["course_enrollment", "skip_refund"]
|
||||
UNENROLL_DONE = Signal()
|
||||
|
||||
# providing_args=["event", "user", "course_id", "mode", "cost", "currency"]
|
||||
ENROLL_STATUS_CHANGE = Signal()
|
||||
|
||||
# providing_args=["course_enrollment"]
|
||||
REFUND_ORDER = Signal()
|
||||
|
||||
@@ -12,7 +12,7 @@ from django.contrib import messages
|
||||
from django.contrib.auth.decorators import login_required
|
||||
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 edx_django_utils import monitoring as monitoring_utils
|
||||
from edx_django_utils.plugins import get_plugins_view_context
|
||||
|
||||
@@ -22,7 +22,7 @@ from django.http import Http404, HttpResponse, HttpResponseBadRequest, HttpRespo
|
||||
from django.shortcuts import redirect
|
||||
from django.template.context_processors import csrf
|
||||
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 csrf_exempt, ensure_csrf_cookie # lint-amnesty, pylint: disable=unused-import
|
||||
from django.views.decorators.http import require_GET, require_http_methods, require_POST # lint-amnesty, pylint: disable=unused-import
|
||||
from edx_ace import ace
|
||||
|
||||
@@ -9,7 +9,7 @@ from django.contrib import admin
|
||||
from django.db import transaction
|
||||
from django.urls import reverse
|
||||
from django.utils.html import format_html
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from .models import (
|
||||
_PSA_OAUTH2_BACKENDS,
|
||||
|
||||
@@ -6,7 +6,7 @@ from django.contrib import messages
|
||||
from django.shortcuts import redirect
|
||||
from django.urls import reverse
|
||||
from django.utils.deprecation import MiddlewareMixin
|
||||
from django.utils.translation import ugettext as _
|
||||
from django.utils.translation import gettext as _
|
||||
from requests import HTTPError
|
||||
from social_django.middleware import SocialAuthExceptionMiddleware
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ from django.contrib.sites.models import Site
|
||||
from django.core.exceptions import ValidationError
|
||||
from django.db import models
|
||||
from django.utils import timezone
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from organizations.models import Organization
|
||||
from social_core.backends.base import BaseAuth
|
||||
from social_core.backends.oauth import OAuthAuth
|
||||
|
||||
@@ -7,7 +7,7 @@ import re
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
import crum
|
||||
from django.utils.translation import get_language, pgettext, ugettext
|
||||
from django.utils.translation import get_language, pgettext, gettext
|
||||
from pytz import UnknownTimeZoneError, timezone, utc
|
||||
|
||||
from lms.djangoapps.courseware.context_processor import user_timezone_locale_prefs
|
||||
@@ -142,7 +142,7 @@ def strftime_localized(dtime, format): # pylint: disable=redefined-builtin
|
||||
# string for formatting dates in a long form. For example, the
|
||||
# American English form is "%A, %B %d %Y".
|
||||
# See http://strftime.org for details.
|
||||
format = ugettext("LONG_DATE_FORMAT")
|
||||
format = gettext("LONG_DATE_FORMAT")
|
||||
if format == "LONG_DATE_FORMAT":
|
||||
format = DEFAULT_LONG_DATE_FORMAT
|
||||
elif format == "DATE_TIME": # lint-amnesty, pylint: disable=comparison-with-callable
|
||||
@@ -150,7 +150,7 @@ def strftime_localized(dtime, format): # pylint: disable=redefined-builtin
|
||||
# string for formatting dates with times. For example, the American
|
||||
# English form is "%b %d, %Y at %H:%M".
|
||||
# See http://strftime.org for details.
|
||||
format = ugettext("DATE_TIME_FORMAT")
|
||||
format = gettext("DATE_TIME_FORMAT")
|
||||
if format == "DATE_TIME_FORMAT":
|
||||
format = DEFAULT_DATE_TIME_FORMAT
|
||||
elif format == "DAY_AND_TIME": # lint-amnesty, pylint: disable=comparison-with-callable
|
||||
@@ -186,7 +186,7 @@ def strftime_localized(dtime, format): # pylint: disable=redefined-builtin
|
||||
# format string for formatting dates in a brief form. For example,
|
||||
# the American English form is "%b %d %Y".
|
||||
# See http://strftime.org for details.
|
||||
actual_format = ugettext("SHORT_DATE_FORMAT")
|
||||
actual_format = gettext("SHORT_DATE_FORMAT")
|
||||
if actual_format == "SHORT_DATE_FORMAT":
|
||||
actual_format = DEFAULT_SHORT_DATE_FORMAT
|
||||
if "%x" in actual_format:
|
||||
@@ -198,7 +198,7 @@ def strftime_localized(dtime, format): # pylint: disable=redefined-builtin
|
||||
# Translators: the translation for "TIME_FORMAT" must be a format
|
||||
# string for formatting times. For example, the American English
|
||||
# form is "%H:%M:%S". See http://strftime.org for details.
|
||||
actual_format = ugettext("TIME_FORMAT")
|
||||
actual_format = gettext("TIME_FORMAT")
|
||||
if actual_format == "TIME_FORMAT":
|
||||
actual_format = DEFAULT_TIME_FORMAT
|
||||
if "%X" in actual_format:
|
||||
|
||||
@@ -9,8 +9,8 @@ from datetime import datetime
|
||||
from django.conf import settings
|
||||
from django.core.exceptions import PermissionDenied
|
||||
from django.core.files.storage import DefaultStorage, get_valid_filename
|
||||
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 pytz import UTC
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ def store_uploaded_file(
|
||||
file_extension = os.path.splitext(uploaded_file.name)[1].lower()
|
||||
if file_extension not in allowed_file_types:
|
||||
file_types = "', '".join(allowed_file_types)
|
||||
msg = ungettext(
|
||||
msg = ngettext(
|
||||
"The file must end with the extension '{file_types}'.",
|
||||
"The file must end with one of the following extensions: '{file_types}'.",
|
||||
len(allowed_file_types)).format(file_types=file_types)
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
Utility library for working with the edx-milestones app
|
||||
"""
|
||||
from django.conf import settings
|
||||
from django.utils.translation import ugettext as _
|
||||
from django.utils.translation import gettext as _
|
||||
from edx_toggles.toggles import SettingDictToggle
|
||||
from milestones import api as milestones_api
|
||||
from milestones.exceptions import InvalidMilestoneRelationshipTypeException, InvalidUserException
|
||||
|
||||
@@ -12,7 +12,8 @@ from eventtracking import tracker
|
||||
# The setting name used for events when "settings" (account settings, preferences, profile information) change.
|
||||
USER_SETTINGS_CHANGED_EVENT_NAME = 'edx.user.settings.changed'
|
||||
# Used to signal a field value change
|
||||
USER_FIELDS_CHANGED = Signal(providing_args=["user", "table", "changed_values"])
|
||||
# providing_args=["user", "table", "changed_values"]
|
||||
USER_FIELDS_CHANGED = Signal()
|
||||
|
||||
|
||||
def get_changed_fields_dict(instance, model_class):
|
||||
|
||||
@@ -11,8 +11,8 @@ from django.contrib.auth.password_validation import MinimumLengthValidator as Dj
|
||||
from django.contrib.auth.password_validation import get_default_password_validators
|
||||
from django.contrib.auth.password_validation import validate_password as django_validate_password
|
||||
from django.core.exceptions import ValidationError
|
||||
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
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
@@ -145,7 +145,7 @@ def _validate_condition(password, fn, min_count):
|
||||
|
||||
class MinimumLengthValidator(DjangoMinimumLengthValidator): # lint-amnesty, pylint: disable=missing-class-docstring
|
||||
def get_instruction_text(self):
|
||||
return ungettext(
|
||||
return ngettext(
|
||||
'at least %(min_length)d character',
|
||||
'at least %(min_length)d characters',
|
||||
self.min_length
|
||||
@@ -171,7 +171,7 @@ class MaximumLengthValidator:
|
||||
def validate(self, password, user=None): # lint-amnesty, pylint: disable=unused-argument
|
||||
if len(password) > self.max_length:
|
||||
raise ValidationError(
|
||||
ungettext(
|
||||
ngettext(
|
||||
'This password is too long. It must contain no more than %(max_length)d character.',
|
||||
'This password is too long. It must contain no more than %(max_length)d characters.',
|
||||
self.max_length
|
||||
@@ -181,7 +181,7 @@ class MaximumLengthValidator:
|
||||
)
|
||||
|
||||
def get_help_text(self):
|
||||
return ungettext(
|
||||
return ngettext(
|
||||
'Your password must contain no more than %(max_length)d character.',
|
||||
'Your password must contain no more than %(max_length)d characters.',
|
||||
self.max_length
|
||||
@@ -209,7 +209,7 @@ class AlphabeticValidator:
|
||||
if _validate_condition(password, lambda c: c.isalpha(), self.min_alphabetic):
|
||||
return
|
||||
raise ValidationError(
|
||||
ungettext(
|
||||
ngettext(
|
||||
'This password must contain at least %(min_alphabetic)d letter.',
|
||||
'This password must contain at least %(min_alphabetic)d letters.',
|
||||
self.min_alphabetic
|
||||
@@ -219,7 +219,7 @@ class AlphabeticValidator:
|
||||
)
|
||||
|
||||
def get_help_text(self):
|
||||
return ungettext(
|
||||
return ngettext(
|
||||
'Your password must contain at least %(min_alphabetic)d letter.',
|
||||
'Your password must contain at least %(min_alphabetic)d letters.',
|
||||
self.min_alphabetic
|
||||
@@ -227,7 +227,7 @@ class AlphabeticValidator:
|
||||
|
||||
def get_instruction_text(self): # lint-amnesty, pylint: disable=missing-function-docstring
|
||||
if self.min_alphabetic > 0:
|
||||
return ungettext(
|
||||
return ngettext(
|
||||
'%(num)d letter',
|
||||
'%(num)d letters',
|
||||
self.min_alphabetic
|
||||
@@ -257,7 +257,7 @@ class NumericValidator:
|
||||
if _validate_condition(password, lambda c: c.isnumeric(), self.min_numeric):
|
||||
return
|
||||
raise ValidationError(
|
||||
ungettext(
|
||||
ngettext(
|
||||
'This password must contain at least %(min_numeric)d number.',
|
||||
'This password must contain at least %(min_numeric)d numbers.',
|
||||
self.min_numeric
|
||||
@@ -267,7 +267,7 @@ class NumericValidator:
|
||||
)
|
||||
|
||||
def get_help_text(self):
|
||||
return ungettext(
|
||||
return ngettext(
|
||||
"Your password must contain at least %(min_numeric)d number.",
|
||||
"Your password must contain at least %(min_numeric)d numbers.",
|
||||
self.min_numeric
|
||||
@@ -275,7 +275,7 @@ class NumericValidator:
|
||||
|
||||
def get_instruction_text(self): # lint-amnesty, pylint: disable=missing-function-docstring
|
||||
if self.min_numeric > 0:
|
||||
return ungettext(
|
||||
return ngettext(
|
||||
'%(num)d number',
|
||||
'%(num)d numbers',
|
||||
self.min_numeric
|
||||
@@ -305,7 +305,7 @@ class UppercaseValidator:
|
||||
if _validate_condition(password, lambda c: c.isupper(), self.min_upper):
|
||||
return
|
||||
raise ValidationError(
|
||||
ungettext(
|
||||
ngettext(
|
||||
'This password must contain at least %(min_upper)d uppercase letter.',
|
||||
'This password must contain at least %(min_upper)d uppercase letters.',
|
||||
self.min_upper
|
||||
@@ -315,7 +315,7 @@ class UppercaseValidator:
|
||||
)
|
||||
|
||||
def get_help_text(self):
|
||||
return ungettext(
|
||||
return ngettext(
|
||||
"Your password must contain at least %(min_upper)d uppercase letter.",
|
||||
"Your password must contain at least %(min_upper)d uppercase letters.",
|
||||
self.min_upper
|
||||
@@ -323,7 +323,7 @@ class UppercaseValidator:
|
||||
|
||||
def get_instruction_text(self): # lint-amnesty, pylint: disable=missing-function-docstring
|
||||
if self.min_upper > 0:
|
||||
return ungettext(
|
||||
return ngettext(
|
||||
'%(num)d uppercase letter',
|
||||
'%(num)d uppercase letters',
|
||||
self.min_upper
|
||||
@@ -353,7 +353,7 @@ class LowercaseValidator:
|
||||
if _validate_condition(password, lambda c: c.islower(), self.min_lower):
|
||||
return
|
||||
raise ValidationError(
|
||||
ungettext(
|
||||
ngettext(
|
||||
'This password must contain at least %(min_lower)d lowercase letter.',
|
||||
'This password must contain at least %(min_lower)d lowercase letters.',
|
||||
self.min_lower
|
||||
@@ -363,7 +363,7 @@ class LowercaseValidator:
|
||||
)
|
||||
|
||||
def get_help_text(self):
|
||||
return ungettext(
|
||||
return ngettext(
|
||||
"Your password must contain at least %(min_lower)d lowercase letter.",
|
||||
"Your password must contain at least %(min_lower)d lowercase letters.",
|
||||
self.min_lower
|
||||
@@ -371,7 +371,7 @@ class LowercaseValidator:
|
||||
|
||||
def get_instruction_text(self): # lint-amnesty, pylint: disable=missing-function-docstring
|
||||
if self.min_lower > 0:
|
||||
return ungettext(
|
||||
return ngettext(
|
||||
'%(num)d lowercase letter',
|
||||
'%(num)d lowercase letters',
|
||||
self.min_lower
|
||||
@@ -402,7 +402,7 @@ class PunctuationValidator:
|
||||
if _validate_condition(password, lambda c: 'P' in unicodedata.category(c), self.min_punctuation):
|
||||
return
|
||||
raise ValidationError(
|
||||
ungettext(
|
||||
ngettext(
|
||||
'This password must contain at least %(min_punctuation)d punctuation mark.',
|
||||
'This password must contain at least %(min_punctuation)d punctuation marks.',
|
||||
self.min_punctuation
|
||||
@@ -412,7 +412,7 @@ class PunctuationValidator:
|
||||
)
|
||||
|
||||
def get_help_text(self):
|
||||
return ungettext(
|
||||
return ngettext(
|
||||
"Your password must contain at least %(min_punctuation)d punctuation mark.",
|
||||
"Your password must contain at least %(min_punctuation)d punctuation marks.",
|
||||
self.min_punctuation
|
||||
@@ -420,7 +420,7 @@ class PunctuationValidator:
|
||||
|
||||
def get_instruction_text(self): # lint-amnesty, pylint: disable=missing-function-docstring
|
||||
if self.min_punctuation > 0:
|
||||
return ungettext(
|
||||
return ngettext(
|
||||
'%(num)d punctuation mark',
|
||||
'%(num)d punctuation marks',
|
||||
self.min_punctuation
|
||||
@@ -450,7 +450,7 @@ class SymbolValidator:
|
||||
if _validate_condition(password, lambda c: 'S' in unicodedata.category(c), self.min_symbol):
|
||||
return
|
||||
raise ValidationError(
|
||||
ungettext(
|
||||
ngettext(
|
||||
'This password must contain at least %(min_symbol)d symbol.',
|
||||
'This password must contain at least %(min_symbol)d symbols.',
|
||||
self.min_symbol
|
||||
@@ -460,7 +460,7 @@ class SymbolValidator:
|
||||
)
|
||||
|
||||
def get_help_text(self):
|
||||
return ungettext(
|
||||
return ngettext(
|
||||
"Your password must contain at least %(min_symbol)d symbol.",
|
||||
"Your password must contain at least %(min_symbol)d symbols.",
|
||||
self.min_symbol
|
||||
@@ -468,7 +468,7 @@ class SymbolValidator:
|
||||
|
||||
def get_instruction_text(self): # lint-amnesty, pylint: disable=missing-function-docstring
|
||||
if self.min_symbol > 0:
|
||||
return ungettext(
|
||||
return ngettext(
|
||||
'%(num)d symbol',
|
||||
'%(num)d symbols',
|
||||
self.min_symbol
|
||||
|
||||
@@ -171,7 +171,7 @@ class StrftimeLocalizedTest(unittest.TestCase):
|
||||
dtime = datetime(2013, 2, 14, 16, 41, 17)
|
||||
assert expected == strftime_localized(dtime, fmt)
|
||||
|
||||
@patch('common.djangoapps.util.date_utils.ugettext', fake_ugettext(translations={
|
||||
@patch('common.djangoapps.util.date_utils.gettext', fake_ugettext(translations={
|
||||
"SHORT_DATE_FORMAT": "date(%Y.%m.%d)",
|
||||
"LONG_DATE_FORMAT": "date(%A.%Y.%B.%d)",
|
||||
"DATE_TIME_FORMAT": "date(%Y.%m.%d@%H.%M)",
|
||||
@@ -191,7 +191,7 @@ class StrftimeLocalizedTest(unittest.TestCase):
|
||||
dtime = datetime(2013, 2, 14, 16, 41, 17)
|
||||
assert expected == strftime_localized(dtime, fmt)
|
||||
|
||||
@patch('common.djangoapps.util.date_utils.ugettext', fake_ugettext(translations={
|
||||
@patch('common.djangoapps.util.date_utils.gettext', fake_ugettext(translations={
|
||||
"SHORT_DATE_FORMAT": "oops date(%Y.%x.%d)",
|
||||
"TIME_FORMAT": "oops %Hh.%Xm.%Ss",
|
||||
}))
|
||||
|
||||
@@ -5,7 +5,7 @@ Django admin dashboard configuration.
|
||||
|
||||
from config_models.admin import ConfigurationModelAdmin, KeyedConfigurationModelAdmin
|
||||
from django.contrib import admin
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from common.djangoapps.xblock_django.models import XBlockConfiguration, XBlockStudioConfiguration, XBlockStudioConfigurationFlag # lint-amnesty, pylint: disable=line-too-long
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ Models.
|
||||
|
||||
from config_models.models import ConfigurationModel
|
||||
from django.db import models
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
|
||||
class XBlockConfiguration(ConfigurationModel):
|
||||
|
||||
@@ -16,7 +16,7 @@ import traceback
|
||||
from bleach.sanitizer import Cleaner
|
||||
from django.conf import settings
|
||||
from django.core.exceptions import ImproperlyConfigured
|
||||
from django.utils.encoding import smart_text
|
||||
from django.utils.encoding import smart_str
|
||||
from django.utils.functional import cached_property
|
||||
from lxml import etree
|
||||
from pkg_resources import resource_string
|
||||
@@ -1215,7 +1215,7 @@ class ProblemBlock(
|
||||
|
||||
content = {
|
||||
'name': self.display_name_with_default,
|
||||
'html': smart_text(html),
|
||||
'html': smart_str(html),
|
||||
'weight': self.weight,
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ from collections import OrderedDict
|
||||
from datetime import datetime
|
||||
|
||||
from pytz import UTC
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from xmodule.util.misc import get_short_labeler
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ import re
|
||||
from abc import abstractmethod
|
||||
|
||||
import xblock
|
||||
from django.utils.translation import ugettext as _
|
||||
from django.utils.translation import gettext as _
|
||||
from lxml import etree
|
||||
from opaque_keys.edx.keys import UsageKey
|
||||
from opaque_keys.edx.locator import LibraryLocator
|
||||
|
||||
@@ -5,7 +5,7 @@ openedx.dynamic_partition plugin.
|
||||
import logging
|
||||
|
||||
from django.conf import settings
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from xmodule.partitions.partitions import (
|
||||
get_partition_from_id,
|
||||
|
||||
@@ -17,7 +17,7 @@ import ddt
|
||||
import requests
|
||||
import webob
|
||||
from codejail.safe_exec import SafeExecException
|
||||
from django.utils.encoding import smart_text
|
||||
from django.utils.encoding import smart_str
|
||||
from edx_user_state_client.interface import XBlockUserState
|
||||
from lxml import etree
|
||||
from opaque_keys.edx.locator import BlockUsageLocator, CourseLocator
|
||||
@@ -2697,7 +2697,7 @@ class ProblemBlockXMLTest(unittest.TestCase): # lint-amnesty, pylint: disable=m
|
||||
capa_content = " FX1_VAL='Καλημέρα' Δοκιμή με μεταβλητές με Ελληνικούς χαρακτήρες μέσα σε python: $FX1_VAL "
|
||||
|
||||
descriptor_dict = descriptor.index_dictionary()
|
||||
assert descriptor_dict['content']['capa_content'] == smart_text(capa_content)
|
||||
assert descriptor_dict['content']['capa_content'] == smart_str(capa_content)
|
||||
|
||||
def test_indexing_checkboxes_with_hints_and_feedback(self):
|
||||
name = "Checkboxes with Hints and Feedback"
|
||||
|
||||
@@ -14,7 +14,7 @@ import pytest
|
||||
import ddt
|
||||
import lxml.etree
|
||||
import pytz
|
||||
from django.utils.translation import ugettext_lazy
|
||||
from django.utils.translation import gettext_lazy
|
||||
from fs.osfs import OSFS
|
||||
from opaque_keys.edx.locator import BlockUsageLocator, CourseLocator
|
||||
from path import Path as path
|
||||
@@ -202,6 +202,6 @@ class TestEdxJsonEncoder(unittest.TestCase):
|
||||
|
||||
# Initializing a lazy text object with Unicode
|
||||
unicode_text = "Your 𝓟𝓵𝓪𝓽𝓯𝓸𝓻𝓶 Name Here"
|
||||
lazy_text = ugettext_lazy(unicode_text) # lint-amnesty, pylint: disable=translation-of-non-string
|
||||
lazy_text = gettext_lazy(unicode_text) # lint-amnesty, pylint: disable=translation-of-non-string
|
||||
|
||||
assert unicode_text == self.encoder.default(lazy_text)
|
||||
|
||||
@@ -1294,7 +1294,7 @@ class StartDateTests(ModuleStoreTestCase):
|
||||
@patch('common.djangoapps.util.date_utils.pgettext', fake_pgettext(translations={
|
||||
("abbreviated month name", "Sep"): "SEPTEMBER",
|
||||
}))
|
||||
@patch('common.djangoapps.util.date_utils.ugettext', fake_ugettext(translations={
|
||||
@patch('common.djangoapps.util.date_utils.gettext', fake_ugettext(translations={
|
||||
"SHORT_DATE_FORMAT": "%Y-%b-%d",
|
||||
}))
|
||||
def test_format_localized_in_studio_course(self):
|
||||
|
||||
Reference in New Issue
Block a user