From d9a91d4c38d8c7d8fcc41a2bcc042470b0b9920a Mon Sep 17 00:00:00 2001 From: "M. Zulqarnain" Date: Thu, 11 Nov 2021 17:52:57 +0500 Subject: [PATCH] BOM-2781: Django codemods on LMS (2) (#28852) * feat: Django codemods on LMS (2) --- lms/djangoapps/course_api/blocks/urls.py | 18 ++--- lms/djangoapps/course_api/urls.py | 10 +-- lms/djangoapps/course_goals/models.py | 2 +- lms/djangoapps/course_goals/urls.py | 4 +- lms/djangoapps/course_home_api/admin.py | 2 +- .../course_metadata/serializers.py | 2 +- .../migrations/0001_initial.py | 2 +- lms/djangoapps/course_home_api/models.py | 4 +- lms/djangoapps/course_wiki/editors.py | 4 +- lms/djangoapps/course_wiki/tab.py | 4 +- lms/djangoapps/course_wiki/views.py | 2 +- lms/djangoapps/courseware/access_response.py | 2 +- lms/djangoapps/courseware/course_tools.py | 2 +- lms/djangoapps/courseware/courses.py | 2 +- lms/djangoapps/courseware/date_summary.py | 14 ++-- lms/djangoapps/courseware/masquerade.py | 2 +- lms/djangoapps/courseware/models.py | 2 +- lms/djangoapps/courseware/plugins.py | 2 +- lms/djangoapps/courseware/tabs.py | 18 ++--- lms/djangoapps/courseware/views/index.py | 2 +- lms/djangoapps/courseware/views/views.py | 26 ++++---- .../django_comment_client/base/urls.py | 65 ++++++++++--------- .../django_comment_client/base/views.py | 2 +- .../discussion/django_comment_client/urls.py | 4 +- lms/djangoapps/discussion/plugins.py | 4 +- lms/djangoapps/discussion/rest_api/urls.py | 18 ++--- lms/djangoapps/discussion/urls.py | 17 +++-- lms/djangoapps/discussion/views.py | 2 +- 28 files changed, 120 insertions(+), 118 deletions(-) diff --git a/lms/djangoapps/course_api/blocks/urls.py b/lms/djangoapps/course_api/blocks/urls.py index bf92b8fc3f..08dbc0ad1e 100644 --- a/lms/djangoapps/course_api/blocks/urls.py +++ b/lms/djangoapps/course_api/blocks/urls.py @@ -4,13 +4,13 @@ Course Block API URLs from django.conf import settings -from django.conf.urls import url +from django.urls import path, re_path from .views import BlocksInCourseView, BlocksView urlpatterns = [ # This endpoint requires the usage_key for the starting block. - url( + re_path( fr'^v1/blocks/{settings.USAGE_KEY_PATTERN}', BlocksView.as_view(), kwargs={'hide_access_denials': True}, @@ -18,22 +18,22 @@ urlpatterns = [ ), # This endpoint is an alternative to the above, but requires course_id as a parameter. - url( - r'^v1/blocks/', + path( + 'v1/blocks/', BlocksInCourseView.as_view(), kwargs={'hide_access_denials': True}, name="blocks_in_course" ), # This endpoint requires the usage_key for the starting block. - url( + re_path( fr'^v2/blocks/{settings.USAGE_KEY_PATTERN}', BlocksView.as_view(), name="blocks_in_block_tree" ), # This endpoint is an alternative to the above, but requires course_id as a parameter. - url( - r'^v2/blocks/', + path( + 'v2/blocks/', BlocksInCourseView.as_view(), name="blocks_in_course" ), @@ -41,8 +41,8 @@ urlpatterns = [ if getattr(settings, 'PROVIDER_STATES_URL', None): from .tests.pacts.views import provider_state - urlpatterns.append(url( - r'^pact/provider_states/$', + urlpatterns.append(path( + 'pact/provider_states/', provider_state, name='provider-state-view' )) diff --git a/lms/djangoapps/course_api/urls.py b/lms/djangoapps/course_api/urls.py index d030f5b8e0..311843b5b6 100644 --- a/lms/djangoapps/course_api/urls.py +++ b/lms/djangoapps/course_api/urls.py @@ -4,13 +4,13 @@ Course API URLs from django.conf import settings -from django.conf.urls import include, url +from django.urls import include, path, re_path from .views import CourseDetailView, CourseIdListView, CourseListView urlpatterns = [ - url(r'^v1/courses/$', CourseListView.as_view(), name="course-list"), - url(fr'^v1/courses/{settings.COURSE_KEY_PATTERN}', CourseDetailView.as_view(), name="course-detail"), - url(r'^v1/course_ids/$', CourseIdListView.as_view(), name="course-id-list"), - url(r'', include('lms.djangoapps.course_api.blocks.urls')) + path('v1/courses/', CourseListView.as_view(), name="course-list"), + re_path(fr'^v1/courses/{settings.COURSE_KEY_PATTERN}', CourseDetailView.as_view(), name="course-detail"), + path('v1/course_ids/', CourseIdListView.as_view(), name="course-id-list"), + path('', include('lms.djangoapps.course_api.blocks.urls')) ] diff --git a/lms/djangoapps/course_goals/models.py b/lms/djangoapps/course_goals/models.py index 0e01e32585..b56b19e15f 100644 --- a/lms/djangoapps/course_goals/models.py +++ b/lms/djangoapps/course_goals/models.py @@ -8,7 +8,7 @@ from datetime import datetime, timedelta 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 edx_django_utils.cache import TieredCache from model_utils import Choices from model_utils.models import TimeStampedModel diff --git a/lms/djangoapps/course_goals/urls.py b/lms/djangoapps/course_goals/urls.py index 9e70db78fd..fd55934ef6 100644 --- a/lms/djangoapps/course_goals/urls.py +++ b/lms/djangoapps/course_goals/urls.py @@ -3,7 +3,7 @@ Course Goals URLs """ -from django.conf.urls import include, url +from django.urls import include, path from rest_framework import routers from .views import CourseGoalViewSet @@ -12,5 +12,5 @@ router = routers.DefaultRouter() router.register(r'course_goals', CourseGoalViewSet, basename='course_goal') urlpatterns = [ - url(r'^v0/', include((router.urls, "api"), namespace='v0')), + path('v0/', include((router.urls, "api"), namespace='v0')), ] diff --git a/lms/djangoapps/course_home_api/admin.py b/lms/djangoapps/course_home_api/admin.py index 6023b1444c..6e65f79020 100644 --- a/lms/djangoapps/course_home_api/admin.py +++ b/lms/djangoapps/course_home_api/admin.py @@ -3,7 +3,7 @@ Django Admin for DisableProgressPageStackedConfig. """ from django.contrib import admin -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from openedx.core.djangoapps.config_model_utils.admin import StackedConfigModelAdmin diff --git a/lms/djangoapps/course_home_api/course_metadata/serializers.py b/lms/djangoapps/course_home_api/course_metadata/serializers.py index 44f43cc507..cef6292cf3 100644 --- a/lms/djangoapps/course_home_api/course_metadata/serializers.py +++ b/lms/djangoapps/course_home_api/course_metadata/serializers.py @@ -6,7 +6,7 @@ Course Home pages. from django.urls import reverse -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from rest_framework import serializers from lms.djangoapps.course_home_api.serializers import VerifiedModeSerializer diff --git a/lms/djangoapps/course_home_api/migrations/0001_initial.py b/lms/djangoapps/course_home_api/migrations/0001_initial.py index 22f16f5ca4..9156e96dbd 100644 --- a/lms/djangoapps/course_home_api/migrations/0001_initial.py +++ b/lms/djangoapps/course_home_api/migrations/0001_initial.py @@ -25,7 +25,7 @@ class Migration(migrations.Migration): ('enabled', models.BooleanField(default=None, null=True, verbose_name='Enabled')), ('org', models.CharField(blank=True, db_index=True, help_text='Configure values for all course runs associated with this Organization. This is the organization string (i.e. edX, MITx).', max_length=255, null=True)), ('org_course', models.CharField(blank=True, db_index=True, help_text="Configure values for all course runs associated with this course. This is should be formatted as 'org+course' (i.e. MITx+6.002x, HarvardX+CS50).", max_length=255, null=True, validators=[openedx.core.djangoapps.config_model_utils.models.validate_course_in_org], verbose_name='Course in Org')), - ('disabled', models.NullBooleanField(default=None, verbose_name='Disabled')), + ('disabled', models.BooleanField(default=None, null=True, verbose_name='Disabled')), ('changed_by', models.ForeignKey(editable=False, null=True, on_delete=django.db.models.deletion.PROTECT, to=settings.AUTH_USER_MODEL, verbose_name='Changed by')), ('course', models.ForeignKey(blank=True, help_text='Configure values for this course run. This should be formatted as the CourseKey (i.e. course-v1://MITx+6.002x+2019_Q1)', null=True, on_delete=django.db.models.deletion.DO_NOTHING, to='course_overviews.CourseOverview', verbose_name='Course Run')), ('site', models.ForeignKey(blank=True, help_text='Configure values for all course runs associated with this site.', null=True, on_delete=django.db.models.deletion.CASCADE, to='sites.Site')), diff --git a/lms/djangoapps/course_home_api/models.py b/lms/djangoapps/course_home_api/models.py index 7a5926aa38..62d1e0fda3 100644 --- a/lms/djangoapps/course_home_api/models.py +++ b/lms/djangoapps/course_home_api/models.py @@ -3,7 +3,7 @@ Course home api models file """ from django.db import models -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from openedx.core.djangoapps.config_model_utils.models import StackedConfigurationModel @@ -17,7 +17,7 @@ class DisableProgressPageStackedConfig(StackedConfigurationModel): # Since this config disables the progress page, # it seemed it would be clearer to use a disabled flag instead of an enabled flag. # The enabled field still exists but is not used or shown in the admin. - disabled = models.NullBooleanField(default=None, verbose_name=_("Disabled")) + disabled = models.BooleanField(default=None, verbose_name=_("Disabled"), null=True) def __str__(self): return "DisableProgressPageStackedConfig(disabled={!r})".format( diff --git a/lms/djangoapps/course_wiki/editors.py b/lms/djangoapps/course_wiki/editors.py index 83de77179c..22ae2a4bb6 100644 --- a/lms/djangoapps/course_wiki/editors.py +++ b/lms/djangoapps/course_wiki/editors.py @@ -6,7 +6,7 @@ Support for using the CodeMirror code editor as a wiki content editor. from django import forms from django.forms.utils import flatatt from django.template.loader import render_to_string -from django.utils.encoding import force_text +from django.utils.encoding import force_str from django.utils.html import conditional_escape from django.utils.safestring import mark_safe from wiki.editors.base import BaseEditor @@ -41,7 +41,7 @@ class CodeMirrorWidget(forms.Widget): return render_to_string('wiki/includes/editor_widget.html', {'attrs': mark_safe(flatatt(final_attrs)), - 'content': conditional_escape(force_text(value)), + 'content': conditional_escape(force_str(value)), }) diff --git a/lms/djangoapps/course_wiki/tab.py b/lms/djangoapps/course_wiki/tab.py index 1f0dc7f3a8..8c87767fe8 100644 --- a/lms/djangoapps/course_wiki/tab.py +++ b/lms/djangoapps/course_wiki/tab.py @@ -5,7 +5,7 @@ a user has on an article. from django.conf import settings -from django.utils.translation import ugettext_noop +from django.utils.translation import gettext_noop from lms.djangoapps.courseware.tabs import EnrolledTab @@ -16,7 +16,7 @@ class WikiTab(EnrolledTab): """ type = "wiki" - title = ugettext_noop('Wiki') + title = gettext_noop('Wiki') view_name = "course_wiki" is_hideable = True is_default = False diff --git a/lms/djangoapps/course_wiki/views.py b/lms/djangoapps/course_wiki/views.py index 2affa2ce13..955bf4e042 100644 --- a/lms/djangoapps/course_wiki/views.py +++ b/lms/djangoapps/course_wiki/views.py @@ -8,7 +8,7 @@ import re from django.conf import settings from django.shortcuts import redirect -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from opaque_keys.edx.keys import CourseKey from wiki.core.exceptions import NoRootURL from wiki.models import Article, URLPath diff --git a/lms/djangoapps/courseware/access_response.py b/lms/djangoapps/courseware/access_response.py index 876dfd7f7b..fbb4b9373b 100644 --- a/lms/djangoapps/courseware/access_response.py +++ b/lms/djangoapps/courseware/access_response.py @@ -3,7 +3,7 @@ This file contains all the classes used by has_access for error handling """ -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from xmodule.course_metadata_utils import DEFAULT_START_DATE diff --git a/lms/djangoapps/courseware/course_tools.py b/lms/djangoapps/courseware/course_tools.py index ff567c0f7b..a60a6cf278 100644 --- a/lms/djangoapps/courseware/course_tools.py +++ b/lms/djangoapps/courseware/course_tools.py @@ -7,7 +7,7 @@ import datetime import pytz from django.conf import settings -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from django.urls import reverse from common.djangoapps.course_modes.models import CourseMode from openedx.features.course_experience.course_tools import CourseTool diff --git a/lms/djangoapps/courseware/courses.py b/lms/djangoapps/courseware/courses.py index b89aa85f36..c46c446fcd 100644 --- a/lms/djangoapps/courseware/courses.py +++ b/lms/djangoapps/courseware/courses.py @@ -13,7 +13,7 @@ from dateutil.parser import parse as parse_date from django.conf import settings from django.http import Http404, QueryDict from django.urls import reverse -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from edx_django_utils.monitoring import function_trace from fs.errors import ResourceNotFound from opaque_keys.edx.keys import UsageKey diff --git a/lms/djangoapps/courseware/date_summary.py b/lms/djangoapps/courseware/date_summary.py index 154a96a3e5..82c0d8ce43 100644 --- a/lms/djangoapps/courseware/date_summary.py +++ b/lms/djangoapps/courseware/date_summary.py @@ -14,8 +14,8 @@ from django.urls import reverse from django.utils.formats import date_format from django.utils.functional import cached_property from django.utils.translation import get_language, to_locale -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 lazy import lazy from pytz import utc @@ -277,8 +277,8 @@ class CourseStartDate(DateSummary): def title(self): enrollment = CourseEnrollment.get_enrollment(self.user, self.course_id) if enrollment and self.course.end and enrollment.created > self.course.end: - return ugettext_lazy('Enrollment Date') - return ugettext_lazy('Course starts') + return gettext_lazy('Enrollment Date') + return gettext_lazy('Course starts') def register_alerts(self, request, course): """ @@ -315,7 +315,7 @@ class CourseEndDate(DateSummary): Displays the end date of the course. """ css_class = 'end-date' - title = ugettext_lazy('Course ends') + title = gettext_lazy('Course ends') is_enabled = True @property @@ -482,7 +482,7 @@ class CertificateAvailableDate(DateSummary): Displays the certificate available date of the course. """ css_class = 'certificate-available-date' - title = ugettext_lazy('Certificate Available') + title = gettext_lazy('Certificate Available') @lazy def is_allowed(self): @@ -544,7 +544,7 @@ class VerifiedUpgradeDeadlineDate(DateSummary): Verified track. """ css_class = 'verified-upgrade-deadline' - link_text = ugettext_lazy('Upgrade to Verified Certificate') + link_text = gettext_lazy('Upgrade to Verified Certificate') @property def link(self): diff --git a/lms/djangoapps/courseware/masquerade.py b/lms/djangoapps/courseware/masquerade.py index b681826154..64b016e838 100644 --- a/lms/djangoapps/courseware/masquerade.py +++ b/lms/djangoapps/courseware/masquerade.py @@ -12,7 +12,7 @@ from django.contrib.auth.decorators import login_required from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user from django.db.models import Q from django.utils.decorators import method_decorator -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from django.views import View from opaque_keys.edx.keys import CourseKey from pytz import utc diff --git a/lms/djangoapps/courseware/models.py b/lms/djangoapps/courseware/models.py index 5ee97fb88a..5aa20a6616 100644 --- a/lms/djangoapps/courseware/models.py +++ b/lms/djangoapps/courseware/models.py @@ -23,7 +23,7 @@ from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imp from django.db import models from django.db.models.signals import post_save -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from model_utils.models import TimeStampedModel from opaque_keys.edx.django.models import BlockTypeKeyField, CourseKeyField, LearningContextKeyField, UsageKeyField from lms.djangoapps.courseware.fields import UnsignedBigIntAutoField diff --git a/lms/djangoapps/courseware/plugins.py b/lms/djangoapps/courseware/plugins.py index 36d77fa6ef..6739628a48 100644 --- a/lms/djangoapps/courseware/plugins.py +++ b/lms/djangoapps/courseware/plugins.py @@ -4,7 +4,7 @@ from typing import Dict, Optional from django import urls from django.conf import settings from django.contrib.auth import get_user_model -from django.utils.translation import ugettext_noop as _ +from django.utils.translation import gettext_noop as _ from opaque_keys.edx.keys import CourseKey from xmodule.modulestore.django import modulestore diff --git a/lms/djangoapps/courseware/tabs.py b/lms/djangoapps/courseware/tabs.py index 7eb8ed27f1..ad351c93d0 100644 --- a/lms/djangoapps/courseware/tabs.py +++ b/lms/djangoapps/courseware/tabs.py @@ -5,8 +5,8 @@ perform some LMS-specific tab display gymnastics for the Entrance Exams feature from django.conf import settings -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 lms.djangoapps.courseware.access import has_access from lms.djangoapps.courseware.entrance_exams import user_can_skip_entrance_exam @@ -33,7 +33,7 @@ class CoursewareTab(EnrolledTab): The main courseware view. """ type = 'courseware' - title = ugettext_noop('Course') + title = gettext_noop('Course') priority = 10 view_name = 'courseware' is_movable = False @@ -68,7 +68,7 @@ class CourseInfoTab(CourseTab): The course info view. """ type = 'course_info' - title = ugettext_noop('Home') + title = gettext_noop('Home') priority = 20 view_name = 'info' tab_id = 'info' @@ -85,7 +85,7 @@ class SyllabusTab(EnrolledTab): A tab for the course syllabus. """ type = 'syllabus' - title = ugettext_noop('Syllabus') + title = gettext_noop('Syllabus') priority = 30 view_name = 'syllabus' allow_multiple = True @@ -103,7 +103,7 @@ class ProgressTab(EnrolledTab): The course progress view. """ type = 'progress' - title = ugettext_noop('Progress') + title = gettext_noop('Progress') priority = 40 view_name = 'progress' is_hideable = True @@ -131,7 +131,7 @@ class TextbookTabsBase(CourseTab): Abstract class for textbook collection tabs classes. """ # Translators: 'Textbooks' refers to the tab in the course that leads to the course' textbooks - title = ugettext_noop("Textbooks") + title = gettext_noop("Textbooks") is_collection = True is_default = False @@ -263,7 +263,7 @@ class ExternalDiscussionCourseTab(LinkTab): type = 'external_discussion' # Translators: 'Discussion' refers to the tab in the courseware that leads to the discussion forums - title = ugettext_noop('Discussion') + title = gettext_noop('Discussion') priority = None is_default = False @@ -326,7 +326,7 @@ class DatesTab(EnrolledTab): A tab representing the relevant dates for a course. """ type = "dates" - title = ugettext_noop( + title = gettext_noop( "Dates") # We don't have the user in this context, so we don't want to translate it at this level. priority = 50 view_name = "dates" diff --git a/lms/djangoapps/courseware/views/index.py b/lms/djangoapps/courseware/views/index.py index 85631f0893..b6b5ec31e2 100644 --- a/lms/djangoapps/courseware/views/index.py +++ b/lms/djangoapps/courseware/views/index.py @@ -16,7 +16,7 @@ from django.template.context_processors import csrf from django.urls import reverse from django.utils.decorators import method_decorator from django.utils.functional import cached_property -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from django.views.decorators.cache import cache_control from django.views.decorators.csrf import ensure_csrf_cookie from django.views.generic import View diff --git a/lms/djangoapps/courseware/views/views.py b/lms/djangoapps/courseware/views/views.py index 8804fa5e9b..895e05be7d 100644 --- a/lms/djangoapps/courseware/views/views.py +++ b/lms/djangoapps/courseware/views/views.py @@ -22,11 +22,11 @@ from django.shortcuts import redirect from django.template.context_processors import csrf from django.urls import reverse from django.utils.decorators import method_decorator -from django.utils.http import urlquote_plus +from urllib.parse import quote_plus from django.utils.text import slugify -from django.utils.translation import ugettext -from django.utils.translation import ugettext_lazy as _ -from django.utils.translation import ugettext_noop +from django.utils.translation import gettext +from django.utils.translation import gettext_lazy as _ +from django.utils.translation import gettext_noop from django.views.decorators.cache import cache_control from django.views.decorators.clickjacking import xframe_options_exempt from django.views.decorators.csrf import ensure_csrf_cookie @@ -680,11 +680,11 @@ class CourseTabView(EdxFragmentView): Text(_("To see course content, {sign_in_link} or {register_link}.")).format( sign_in_link=HTML('{sign_in_label}').format( sign_in_label=_("sign in"), - current_url=urlquote_plus(request.path), + current_url=quote_plus(request.path), ), register_link=HTML('{register_label}').format( register_label=_("register"), - current_url=urlquote_plus(request.path), + current_url=quote_plus(request.path), ), ), once_only=True @@ -695,11 +695,11 @@ class CourseTabView(EdxFragmentView): Text(_("{sign_in_link} or {register_link}.")).format( sign_in_link=HTML('{sign_in_label}').format( sign_in_label=_("Sign in"), - current_url=urlquote_plus(request.path), + current_url=quote_plus(request.path), ), register_link=HTML('{register_label}').format( register_label=_("register"), - current_url=urlquote_plus(request.path), + current_url=quote_plus(request.path), ), ) ) @@ -1907,11 +1907,11 @@ def _get_fa_header(header): platform_name=configuration_helpers.get_value('PLATFORM_NAME', settings.PLATFORM_NAME)).split('\n') -FA_INCOME_LABEL = ugettext_noop('Annual Household Income') -FA_REASON_FOR_APPLYING_LABEL = ugettext_noop('Tell us about your current financial situation. Why do you need assistance?') # lint-amnesty, pylint: disable=line-too-long -FA_GOALS_LABEL = ugettext_noop('Tell us about your learning or professional goals. How will a Verified Certificate in this course help you achieve these goals?') # lint-amnesty, pylint: disable=line-too-long +FA_INCOME_LABEL = gettext_noop('Annual Household Income') +FA_REASON_FOR_APPLYING_LABEL = gettext_noop('Tell us about your current financial situation. Why do you need assistance?') # lint-amnesty, pylint: disable=line-too-long +FA_GOALS_LABEL = gettext_noop('Tell us about your learning or professional goals. How will a Verified Certificate in this course help you achieve these goals?') # lint-amnesty, pylint: disable=line-too-long -FA_EFFORT_LABEL = ugettext_noop('Tell us about your plans for this course. What steps will you take to help you complete the course work and receive a certificate?') # lint-amnesty, pylint: disable=line-too-long +FA_EFFORT_LABEL = gettext_noop('Tell us about your plans for this course. What steps will you take to help you complete the course work and receive a certificate?') # lint-amnesty, pylint: disable=line-too-long FA_SHORT_ANSWER_INSTRUCTIONS = _('Use between 1250 and 2500 characters or so in your response.') @@ -2026,7 +2026,7 @@ def financial_assistance_form(request): 'defaultValue': '', 'required': True, 'options': enrolled_courses, - 'instructions': ugettext( + 'instructions': gettext( 'Select the course for which you want to earn a verified certificate. If' ' the course does not appear in the list, make sure that you have enrolled' ' in the audit track for the course.' diff --git a/lms/djangoapps/discussion/django_comment_client/base/urls.py b/lms/djangoapps/discussion/django_comment_client/base/urls.py index 0ce29732b5..72c2c3059d 100644 --- a/lms/djangoapps/discussion/django_comment_client/base/urls.py +++ b/lms/djangoapps/discussion/django_comment_client/base/urls.py @@ -3,39 +3,42 @@ Base urls for the django_comment_client. """ -from django.conf.urls import url +from django.urls import path, re_path from lms.djangoapps.discussion.django_comment_client.base import views urlpatterns = [ - url(r'^upload$', views.upload, name='upload'), - url(r'^threads/(?P[\w\-]+)/update$', views.update_thread, name='update_thread'), - url(r'^threads/(?P[\w\-]+)/reply$', views.create_comment, name='create_comment'), - url(r'^threads/(?P[\w\-]+)/delete', views.delete_thread, name='delete_thread'), - url(r'^threads/(?P[\w\-]+)/upvote$', views.vote_for_thread, {'value': 'up'}, name='upvote_thread'), - url(r'^threads/(?P[\w\-]+)/downvote$', views.vote_for_thread, {'value': 'down'}, name='downvote_thread'), - url(r'^threads/(?P[\w\-]+)/flagAbuse$', views.flag_abuse_for_thread, name='flag_abuse_for_thread'), - url(r'^threads/(?P[\w\-]+)/unFlagAbuse$', views.un_flag_abuse_for_thread, - name='un_flag_abuse_for_thread'), - url(r'^threads/(?P[\w\-]+)/unvote$', views.undo_vote_for_thread, name='undo_vote_for_thread'), - url(r'^threads/(?P[\w\-]+)/pin$', views.pin_thread, name='pin_thread'), - url(r'^threads/(?P[\w\-]+)/unpin$', views.un_pin_thread, name='un_pin_thread'), - url(r'^threads/(?P[\w\-]+)/follow$', views.follow_thread, name='follow_thread'), - url(r'^threads/(?P[\w\-]+)/unfollow$', views.unfollow_thread, name='unfollow_thread'), - url(r'^threads/(?P[\w\-]+)/close$', views.openclose_thread, name='openclose_thread'), - url(r'^comments/(?P[\w\-]+)/update$', views.update_comment, name='update_comment'), - url(r'^comments/(?P[\w\-]+)/endorse$', views.endorse_comment, name='endorse_comment'), - url(r'^comments/(?P[\w\-]+)/reply$', views.create_sub_comment, name='create_sub_comment'), - url(r'^comments/(?P[\w\-]+)/delete$', views.delete_comment, name='delete_comment'), - url(r'^comments/(?P[\w\-]+)/upvote$', views.vote_for_comment, {'value': 'up'}, name='upvote_comment'), - url(r'^comments/(?P[\w\-]+)/downvote$', views.vote_for_comment, {'value': 'down'}, - name='downvote_comment'), - url(r'^comments/(?P[\w\-]+)/unvote$', views.undo_vote_for_comment, name='undo_vote_for_comment'), - url(r'^comments/(?P[\w\-]+)/flagAbuse$', views.flag_abuse_for_comment, name='flag_abuse_for_comment'), - url(r'^comments/(?P[\w\-]+)/unFlagAbuse$', views.un_flag_abuse_for_comment, - name='un_flag_abuse_for_comment'), - url(r'^(?P[\w\-.]+)/threads/create$', views.create_thread, name='create_thread'), - url(r'^(?P[\w\-.]+)/follow$', views.follow_commentable, name='follow_commentable'), - url(r'^(?P[\w\-.]+)/unfollow$', views.unfollow_commentable, name='unfollow_commentable'), - url(r'^users$', views.users, name='users'), + path('upload', views.upload, name='upload'), + re_path(r'^threads/(?P[\w\-]+)/update$', views.update_thread, name='update_thread'), + re_path(r'^threads/(?P[\w\-]+)/reply$', views.create_comment, name='create_comment'), + re_path(r'^threads/(?P[\w\-]+)/delete', views.delete_thread, name='delete_thread'), + re_path(r'^threads/(?P[\w\-]+)/upvote$', views.vote_for_thread, {'value': 'up'}, name='upvote_thread'), + re_path(r'^threads/(?P[\w\-]+)/downvote$', views.vote_for_thread, {'value': 'down'}, + name='downvote_thread'), + re_path(r'^threads/(?P[\w\-]+)/flagAbuse$', views.flag_abuse_for_thread, name='flag_abuse_for_thread'), + re_path(r'^threads/(?P[\w\-]+)/unFlagAbuse$', views.un_flag_abuse_for_thread, + name='un_flag_abuse_for_thread'), + re_path(r'^threads/(?P[\w\-]+)/unvote$', views.undo_vote_for_thread, name='undo_vote_for_thread'), + re_path(r'^threads/(?P[\w\-]+)/pin$', views.pin_thread, name='pin_thread'), + re_path(r'^threads/(?P[\w\-]+)/unpin$', views.un_pin_thread, name='un_pin_thread'), + re_path(r'^threads/(?P[\w\-]+)/follow$', views.follow_thread, name='follow_thread'), + re_path(r'^threads/(?P[\w\-]+)/unfollow$', views.unfollow_thread, name='unfollow_thread'), + re_path(r'^threads/(?P[\w\-]+)/close$', views.openclose_thread, name='openclose_thread'), + re_path(r'^comments/(?P[\w\-]+)/update$', views.update_comment, name='update_comment'), + re_path(r'^comments/(?P[\w\-]+)/endorse$', views.endorse_comment, name='endorse_comment'), + re_path(r'^comments/(?P[\w\-]+)/reply$', views.create_sub_comment, name='create_sub_comment'), + re_path(r'^comments/(?P[\w\-]+)/delete$', views.delete_comment, name='delete_comment'), + re_path(r'^comments/(?P[\w\-]+)/upvote$', views.vote_for_comment, + {'value': 'up'}, name='upvote_comment'), + re_path(r'^comments/(?P[\w\-]+)/downvote$', views.vote_for_comment, {'value': 'down'}, + name='downvote_comment'), + re_path(r'^comments/(?P[\w\-]+)/unvote$', views.undo_vote_for_comment, name='undo_vote_for_comment'), + re_path(r'^comments/(?P[\w\-]+)/flagAbuse$', views.flag_abuse_for_comment, + name='flag_abuse_for_comment'), + re_path(r'^comments/(?P[\w\-]+)/unFlagAbuse$', views.un_flag_abuse_for_comment, + name='un_flag_abuse_for_comment'), + re_path(r'^(?P[\w\-.]+)/threads/create$', views.create_thread, name='create_thread'), + re_path(r'^(?P[\w\-.]+)/follow$', views.follow_commentable, name='follow_commentable'), + re_path(r'^(?P[\w\-.]+)/unfollow$', views.unfollow_commentable, name='unfollow_commentable'), + path('users', views.users, name='users'), ] diff --git a/lms/djangoapps/discussion/django_comment_client/base/views.py b/lms/djangoapps/discussion/django_comment_client/base/views.py index 509724b0a3..1ab144be28 100644 --- a/lms/djangoapps/discussion/django_comment_client/base/views.py +++ b/lms/djangoapps/discussion/django_comment_client/base/views.py @@ -11,7 +11,7 @@ from django.contrib.auth.decorators import login_required from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user from django.core import exceptions from django.http import Http404, HttpResponse, HttpResponseServerError -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from django.views.decorators import csrf from django.views.decorators.clickjacking import xframe_options_exempt from django.views.decorators.http import require_GET, require_POST diff --git a/lms/djangoapps/discussion/django_comment_client/urls.py b/lms/djangoapps/discussion/django_comment_client/urls.py index d8cf4d4db2..ecfc8a133e 100644 --- a/lms/djangoapps/discussion/django_comment_client/urls.py +++ b/lms/djangoapps/discussion/django_comment_client/urls.py @@ -3,8 +3,8 @@ Urls for the django_comment_client. """ -from django.conf.urls import include, url +from django.urls import include, path urlpatterns = [ - url(r'', include('lms.djangoapps.discussion.django_comment_client.base.urls')), + path('', include('lms.djangoapps.discussion.django_comment_client.base.urls')), ] diff --git a/lms/djangoapps/discussion/plugins.py b/lms/djangoapps/discussion/plugins.py index 915ed31e3f..d835761ea3 100644 --- a/lms/djangoapps/discussion/plugins.py +++ b/lms/djangoapps/discussion/plugins.py @@ -4,7 +4,7 @@ Views handling read (GET) requests for the Discussion tab and inline discussions from django.conf import settings -from django.utils.translation import ugettext_noop +from django.utils.translation import gettext_noop import lms.djangoapps.discussion.django_comment_client.utils as utils from lms.djangoapps.courseware.tabs import EnrolledTab @@ -18,7 +18,7 @@ class DiscussionTab(TabFragmentViewMixin, EnrolledTab): """ type = 'discussion' - title = ugettext_noop('Discussion') + title = gettext_noop('Discussion') priority = None view_name = 'forum_form_discussion' fragment_view_name = 'lms.djangoapps.discussion.views.DiscussionBoardFragmentView' diff --git a/lms/djangoapps/discussion/rest_api/urls.py b/lms/djangoapps/discussion/rest_api/urls.py index f915122ab7..f3ab5c46f1 100644 --- a/lms/djangoapps/discussion/rest_api/urls.py +++ b/lms/djangoapps/discussion/rest_api/urls.py @@ -5,7 +5,7 @@ Discussion API URLs from django.conf import settings -from django.conf.urls import include, url +from django.urls import include, path, re_path from rest_framework.routers import SimpleRouter from lms.djangoapps.discussion.rest_api.views import ( @@ -25,36 +25,36 @@ ROUTER.register("threads", ThreadViewSet, basename="thread") ROUTER.register("comments", CommentViewSet, basename="comment") urlpatterns = [ - url( + re_path( r"^v1/courses/{}/settings$".format( settings.COURSE_ID_PATTERN ), CourseDiscussionSettingsAPIView.as_view(), name="discussion_course_settings", ), - url( + re_path( fr"^v1/courses/{settings.COURSE_ID_PATTERN}/upload$", UploadFileView.as_view(), name="upload_file", ), - url( + re_path( r"^v1/courses/{}/roles/(?P[A-Za-z0-9+ _-]+)/?$".format( settings.COURSE_ID_PATTERN ), CourseDiscussionRolesAPIView.as_view(), name="discussion_course_roles", ), - url( + re_path( fr"^v1/courses/{settings.COURSE_ID_PATTERN}", CourseView.as_view(), name="discussion_course" ), - url(r"^v1/accounts/retire_forum", RetireUserView.as_view(), name="retire_discussion_user"), - url(r"^v1/accounts/replace_username", ReplaceUsernamesView.as_view(), name="replace_discussion_username"), - url( + path('v1/accounts/retire_forum', RetireUserView.as_view(), name="retire_discussion_user"), + path('v1/accounts/replace_username', ReplaceUsernamesView.as_view(), name="replace_discussion_username"), + re_path( fr"^v1/course_topics/{settings.COURSE_ID_PATTERN}", CourseTopicsView.as_view(), name="course_topics" ), - url("^v1/", include(ROUTER.urls)), + path('v1/', include(ROUTER.urls)), ] diff --git a/lms/djangoapps/discussion/urls.py b/lms/djangoapps/discussion/urls.py index 01f94dc443..a459e3dc42 100644 --- a/lms/djangoapps/discussion/urls.py +++ b/lms/djangoapps/discussion/urls.py @@ -3,20 +3,19 @@ Forum urls for the django_comment_client. """ -from django.conf.urls import url +from django.urls import path, re_path from . import views urlpatterns = [ - url(r'users/(?P\w+)/followed$', views.followed_threads, name='followed_threads'), - url(r'users/(?P\w+)$', views.user_profile, name='user_profile'), - url(r'^(?P[\w\-.]+)/threads/(?P\w+)$', views.single_thread, - name='single_thread'), - url(r'^(?P[\w\-.]+)/inline$', views.inline_discussion, name='inline_discussion'), - url( - r'discussion_board_fragment_view$', + re_path(r'users/(?P\w+)/followed$', views.followed_threads, name='followed_threads'), + re_path(r'users/(?P\w+)$', views.user_profile, name='user_profile'), + re_path(r'^(?P[\w\-.]+)/threads/(?P\w+)$', views.single_thread, name='single_thread'), + re_path(r'^(?P[\w\-.]+)/inline$', views.inline_discussion, name='inline_discussion'), + path( + 'discussion_board_fragment_view', views.DiscussionBoardFragmentView.as_view(), name='discussion_board_fragment_view' ), - url(r'', views.forum_form_discussion, name='forum_form_discussion'), + re_path('', views.forum_form_discussion, name='forum_form_discussion'), ] diff --git a/lms/djangoapps/discussion/views.py b/lms/djangoapps/discussion/views.py index 4f8f235095..6cfdf37101 100644 --- a/lms/djangoapps/discussion/views.py +++ b/lms/djangoapps/discussion/views.py @@ -14,7 +14,7 @@ from django.shortcuts import render from django.template.context_processors import csrf from django.template.loader import render_to_string from django.urls import reverse -from django.utils.translation import get_language_bidi, ugettext_lazy as _ +from django.utils.translation import get_language_bidi, gettext_lazy as _ from django.views.decorators.cache import cache_control from django.views.decorators.csrf import ensure_csrf_cookie from django.views.decorators.http import require_GET, require_http_methods