Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion common/djangoapps/course_modes/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
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

Expand Down
2 changes: 1 addition & 1 deletion common/djangoapps/course_modes/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion common/djangoapps/course_modes/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
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
Expand Down
2 changes: 1 addition & 1 deletion common/djangoapps/course_modes/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
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
Expand Down
25 changes: 12 additions & 13 deletions common/djangoapps/static_replace/test/test_static_replace.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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():
Expand All @@ -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"'
Expand All @@ -69,15 +68,15 @@ def processor(__, prefix, quote, rest):
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


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"'
Expand Down Expand Up @@ -534,11 +533,11 @@ def create_arbitrary_content(cls, prefix, name, locked=False):
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
Expand All @@ -565,7 +564,7 @@ def test_canonical_asset_path_with_new_style_assets(self, base_url, start, expec
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,
Expand Down Expand Up @@ -747,8 +746,8 @@ def test_canonical_asset_path_with_c4x_style_assets(self, base_url, start, expec
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(
Expand All @@ -765,7 +764,7 @@ def test_canonical_asset_path_with_c4x_style_assets(self, base_url, start, expec
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,
Expand Down
2 changes: 1 addition & 1 deletion common/djangoapps/student/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
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

Expand Down
2 changes: 1 addition & 1 deletion common/djangoapps/student/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from django.core.validators import ValidationError
from django.db import IntegrityError, transaction, ProgrammingError
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
Expand Down
2 changes: 1 addition & 1 deletion common/djangoapps/student/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
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
Expand Down
28 changes: 14 additions & 14 deletions common/djangoapps/student/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@
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
Expand Down Expand Up @@ -528,10 +528,10 @@ class Meta:
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
Expand All @@ -542,17 +542,17 @@ class Meta:
# ('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,
Expand Down
18 changes: 14 additions & 4 deletions common/djangoapps/student/signals/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,17 @@

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()
2 changes: 1 addition & 1 deletion common/djangoapps/student/views/dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
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
Expand Down
2 changes: 1 addition & 1 deletion common/djangoapps/student/views/management.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
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
Expand Down
2 changes: 1 addition & 1 deletion common/djangoapps/third_party_auth/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
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,
Expand Down
2 changes: 1 addition & 1 deletion common/djangoapps/third_party_auth/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
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

Expand Down
2 changes: 1 addition & 1 deletion common/djangoapps/third_party_auth/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
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
Expand Down
10 changes: 5 additions & 5 deletions common/djangoapps/util/date_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
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
Expand Down Expand Up @@ -142,15 +142,15 @@ 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
# Translators: the translation for "DATE_TIME_FORMAT" must be a format
# 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
Expand Down Expand Up @@ -186,7 +186,7 @@ def process_percent_code(match):
# 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:
Expand All @@ -198,7 +198,7 @@ def process_percent_code(match):
# 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:
Expand Down
6 changes: 3 additions & 3 deletions common/djangoapps/util/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
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


Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion common/djangoapps/util/milestones_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion common/djangoapps/util/model_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
# 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):
Expand Down
Loading