diff --git a/lms/djangoapps/edxnotes/api_urls.py b/lms/djangoapps/edxnotes/api_urls.py index 1ac92b69ee..b87101f45b 100644 --- a/lms/djangoapps/edxnotes/api_urls.py +++ b/lms/djangoapps/edxnotes/api_urls.py @@ -3,10 +3,10 @@ API URLs for EdxNotes """ -from django.conf.urls import url +from django.urls import path from lms.djangoapps.edxnotes import views urlpatterns = [ - url(r"^retire_user/$", views.RetireUserView.as_view(), name="edxnotes_retire_user"), + path('retire_user/', views.RetireUserView.as_view(), name="edxnotes_retire_user"), ] diff --git a/lms/djangoapps/edxnotes/helpers.py b/lms/djangoapps/edxnotes/helpers.py index 70b26d8041..ca4df678d4 100644 --- a/lms/djangoapps/edxnotes/helpers.py +++ b/lms/djangoapps/edxnotes/helpers.py @@ -15,7 +15,7 @@ from dateutil.parser import parse as dateutil_parse from django.conf import settings from django.core.exceptions import ImproperlyConfigured from django.urls import reverse -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from oauth2_provider.models import Application from opaque_keys.edx.keys import UsageKey from requests.exceptions import RequestException diff --git a/lms/djangoapps/edxnotes/urls.py b/lms/djangoapps/edxnotes/urls.py index b2b6696e2f..8a43ac2b42 100644 --- a/lms/djangoapps/edxnotes/urls.py +++ b/lms/djangoapps/edxnotes/urls.py @@ -3,14 +3,14 @@ URLs for EdxNotes. """ -from django.conf.urls import url +from django.urls import path from . import views # Additionally, we include login URLs for the browseable API. urlpatterns = [ - url(r"^$", views.edxnotes, name="edxnotes"), - url(r"^notes/$", views.notes, name="notes"), - url(r"^token/$", views.get_token, name="get_token"), - url(r"^visibility/$", views.edxnotes_visibility, name="edxnotes_visibility"), + path('', views.edxnotes, name="edxnotes"), + path('notes/', views.notes, name="notes"), + path('token/', views.get_token, name="get_token"), + path('visibility/', views.edxnotes_visibility, name="edxnotes_visibility"), ] diff --git a/lms/djangoapps/experiments/urls.py b/lms/djangoapps/experiments/urls.py index 005c9ed0d2..e192e2e971 100644 --- a/lms/djangoapps/experiments/urls.py +++ b/lms/djangoapps/experiments/urls.py @@ -3,7 +3,7 @@ Experimentation URLs """ from django.conf import settings -from django.conf.urls import include, url +from django.urls import include, path, re_path from . import routers, views, views_custom @@ -12,9 +12,9 @@ router.register(r'data', views.ExperimentDataViewSet, basename='data') router.register(r'key-value', views.ExperimentKeyValueViewSet, basename='key_value') urlpatterns = [ - url(r'^v0/custom/REV-934/', views_custom.Rev934.as_view(), name='rev_934'), - url(r'^v0/', include((router.urls, "api"), namespace='v0')), - url(r'^v0/custom/userMetadata/{username},{course_key}$'.format( + path('v0/custom/REV-934/', views_custom.Rev934.as_view(), name='rev_934'), + path('v0/', include((router.urls, "api"), namespace='v0')), + re_path(r'^v0/custom/userMetadata/{username},{course_key}$'.format( username=settings.USERNAME_PATTERN, course_key=settings.COURSE_ID_PATTERN), views.UserMetaDataView.as_view(), name='user_metadata'), ] diff --git a/lms/djangoapps/grades/rest_api/urls.py b/lms/djangoapps/grades/rest_api/urls.py index ee9918f4dc..c6b22d312b 100644 --- a/lms/djangoapps/grades/rest_api/urls.py +++ b/lms/djangoapps/grades/rest_api/urls.py @@ -3,10 +3,10 @@ Grades API URLs. """ -from django.conf.urls import include, url +from django.urls import include, path app_name = 'lms.djangoapps.grades' urlpatterns = [ - url(r'^v1/', include('lms.djangoapps.grades.rest_api.v1.urls', namespace='v1')) + path('v1/', include('lms.djangoapps.grades.rest_api.v1.urls', namespace='v1')) ] diff --git a/lms/djangoapps/grades/rest_api/v1/gradebook_views.py b/lms/djangoapps/grades/rest_api/v1/gradebook_views.py index a064e759af..7e0328707d 100644 --- a/lms/djangoapps/grades/rest_api/v1/gradebook_views.py +++ b/lms/djangoapps/grades/rest_api/v1/gradebook_views.py @@ -12,7 +12,7 @@ from django.contrib.auth import get_user_model from django.core.cache import cache from django.db.models import Case, Exists, F, OuterRef, Q, When from django.urls import reverse -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, UsageKey from rest_framework import status diff --git a/lms/djangoapps/grades/rest_api/v1/urls.py b/lms/djangoapps/grades/rest_api/v1/urls.py index 081e62b419..498b26467e 100644 --- a/lms/djangoapps/grades/rest_api/v1/urls.py +++ b/lms/djangoapps/grades/rest_api/v1/urls.py @@ -2,44 +2,44 @@ from django.conf import settings -from django.conf.urls import url +from django.urls import path, re_path from lms.djangoapps.grades.rest_api.v1 import gradebook_views, views app_name = 'lms.djangoapps.grades' urlpatterns = [ - url( - r'^courses/$', + path( + 'courses/', views.CourseGradesView.as_view(), name='course_grades' ), - url( + re_path( fr'^courses/{settings.COURSE_ID_PATTERN}/$', views.CourseGradesView.as_view(), name='course_grades' ), - url( + re_path( fr'^policy/courses/{settings.COURSE_ID_PATTERN}/$', views.CourseGradingPolicy.as_view(), name='course_grading_policy' ), - url( + re_path( fr'^gradebook/{settings.COURSE_ID_PATTERN}/$', gradebook_views.GradebookView.as_view(), name='course_gradebook' ), - url( + re_path( fr'^gradebook/{settings.COURSE_ID_PATTERN}/bulk-update$', gradebook_views.GradebookBulkUpdateView.as_view(), name='course_gradebook_bulk_update' ), - url( + re_path( fr'^gradebook/{settings.COURSE_ID_PATTERN}/grading-info$', gradebook_views.CourseGradingView.as_view(), name='course_gradebook_grading_info' ), - url( + re_path( r'^subsection/(?P.*)/$', gradebook_views.SubsectionGradeView.as_view(), name='course_grade_overrides' diff --git a/lms/djangoapps/grades/signals/signals.py b/lms/djangoapps/grades/signals/signals.py index 3a569588ca..0edd48b4d5 100644 --- a/lms/djangoapps/grades/signals/signals.py +++ b/lms/djangoapps/grades/signals/signals.py @@ -14,23 +14,22 @@ from django.dispatch import Signal # regardless of the new and previous values of the score (i.e. it may be the # case that this signal is generated when a user re-attempts a problem but # receives the same score). -PROBLEM_RAW_SCORE_CHANGED = Signal( - providing_args=[ - 'user_id', # Integer User ID - 'course_id', # Unicode string representing the course - 'usage_id', # Unicode string indicating the courseware instance - 'raw_earned', # Score obtained by the user - 'raw_possible', # Maximum score available for the exercise - 'weight', # Weight of the problem - 'only_if_higher', # Boolean indicating whether updates should be - # made only if the new score is higher than previous. - 'modified', # A datetime indicating when the database representation of - # this the problem score was saved. - 'score_db_table', # The database table that houses the score that changed. - 'score_deleted', # Boolean indicating whether the score changed due to - # the user state being deleted. - ] -) +# providing_args=[ +# 'user_id', # Integer User ID +# 'course_id', # Unicode string representing the course +# 'usage_id', # Unicode string indicating the courseware instance +# 'raw_earned', # Score obtained by the user +# 'raw_possible', # Maximum score available for the exercise +# 'weight', # Weight of the problem +# 'only_if_higher', # Boolean indicating whether updates should be +# # made only if the new score is higher than previous. +# 'modified', # A datetime indicating when the database representation of +# # this the problem score was saved. +# 'score_db_table', # The database table that houses the score that changed. +# 'score_deleted', # Boolean indicating whether the score changed due to +# # the user state being deleted. +# ] +PROBLEM_RAW_SCORE_CHANGED = Signal() # Signal that indicates that a user's weighted score for a problem has been updated. # This signal is generated when a scoring event occurs in the Submissions module @@ -39,81 +38,76 @@ PROBLEM_RAW_SCORE_CHANGED = Signal( # regardless of the new and previous values of the score (i.e. it may be the # case that this signal is generated when a user re-attempts a problem but # receives the same score). -PROBLEM_WEIGHTED_SCORE_CHANGED = Signal( - providing_args=[ - 'user_id', # Integer User ID - 'anonymous_user_id', # Anonymous User ID - 'course_id', # Unicode string representing the course - 'usage_id', # Unicode string indicating the courseware instance - 'weighted_earned', # Score obtained by the user - 'weighted_possible', # Maximum score available for the exercise - 'only_if_higher', # Boolean indicating whether updates should be - # made only if the new score is higher than previous. - 'modified', # A datetime indicating when the database representation of - # this the problem score was saved. - 'score_db_table', # The database table that houses the score that changed. - 'score_deleted', # Boolean indicating whether the score changed due to - # the user state being deleted. - ] -) +# providing_args=[ +# 'user_id', # Integer User ID +# 'anonymous_user_id', # Anonymous User ID +# 'course_id', # Unicode string representing the course +# 'usage_id', # Unicode string indicating the courseware instance +# 'weighted_earned', # Score obtained by the user +# 'weighted_possible', # Maximum score available for the exercise +# 'only_if_higher', # Boolean indicating whether updates should be +# # made only if the new score is higher than previous. +# 'modified', # A datetime indicating when the database representation of +# # this the problem score was saved. +# 'score_db_table', # The database table that houses the score that changed. +# 'score_deleted', # Boolean indicating whether the score changed due to +# # the user state being deleted. +# ] +PROBLEM_WEIGHTED_SCORE_CHANGED = Signal() # Signal that indicates that a user's score for a problem has been published # for possible persistence and update. Typically, most clients should listen # to the PROBLEM_WEIGHTED_SCORE_CHANGED signal instead, since that is signalled # only after the problem's score is changed. -SCORE_PUBLISHED = Signal( - providing_args=[ - 'block', # Course block object - 'user', # User object - 'raw_earned', # Score obtained by the user - 'raw_possible', # Maximum score available for the exercise - 'only_if_higher', # Boolean indicating whether updates should be - # made only if the new score is higher than previous. - 'score_db_table', # The database table that houses the score that changed. - ] -) +# providing_args=[ +# 'block', # Course block object +# 'user', # User object +# 'raw_earned', # Score obtained by the user +# 'raw_possible', # Maximum score available for the exercise +# 'only_if_higher', # Boolean indicating whether updates should be +# # made only if the new score is higher than previous. +# 'score_db_table', # The database table that houses the score that changed. +# ] +SCORE_PUBLISHED = Signal() # Signal that indicates that a user's score for a subsection has been updated. # This is a downstream signal of PROBLEM_WEIGHTED_SCORE_CHANGED sent for each # affected containing subsection. -SUBSECTION_SCORE_CHANGED = Signal( - providing_args=[ - 'course', # Course object - 'course_structure', # BlockStructure object - 'user', # User object - 'subsection_grade', # SubsectionGrade object - ] -) +# providing_args=[ +# 'course', # Course object +# 'course_structure', # BlockStructure object +# 'user', # User object +# 'subsection_grade', # SubsectionGrade object +# ] +SUBSECTION_SCORE_CHANGED = Signal() # Signal that indicates that a user's score for a subsection has been overridden. # This signal is generated when a user's exam attempt state is set to rejected or # to verified from rejected. This signal may also be sent by any other client # using the GradesService to override subsections in the future. -SUBSECTION_OVERRIDE_CHANGED = Signal( - providing_args=[ - 'user_id', # Integer User ID - 'course_id', # Unicode string representing the course - 'usage_id', # Unicode string indicating the courseware instance - 'only_if_higher', # Boolean indicating whether updates should be - # made only if the new score is higher than previous. - 'modified', # A datetime indicating when the database representation of - # this subsection override score was saved. - 'score_deleted', # Boolean indicating whether the override score was - # deleted in this event. - 'score_db_table', # The database table that houses the subsection override - # score that was created. - ] -) +# providing_args=[ +# 'user_id', # Integer User ID +# 'course_id', # Unicode string representing the course +# 'usage_id', # Unicode string indicating the courseware instance +# 'only_if_higher', # Boolean indicating whether updates should be +# # made only if the new score is higher than previous. +# 'modified', # A datetime indicating when the database representation of +# # this subsection override score was saved. +# 'score_deleted', # Boolean indicating whether the override score was +# # deleted in this event. +# 'score_db_table', # The database table that houses the subsection override +# # score that was created. +# ] +SUBSECTION_OVERRIDE_CHANGED = Signal() # This Signal indicates that the user has received a passing grade in the course for the first time. # Any subsequent grade changes that may vary the passing/failing status will not re-trigger this event. # Emits course grade passed first time event -COURSE_GRADE_PASSED_FIRST_TIME = Signal( - providing_args=[ - 'course_id', # Course object id - 'user_id', # User object id - ] -) +# providing_args=[ +# 'course_id', # Course object id +# 'user_id', # User object id +# ] +COURSE_GRADE_PASSED_FIRST_TIME = Signal() diff --git a/lms/djangoapps/instructor/services.py b/lms/djangoapps/instructor/services.py index ba23c0e2d9..71f355c452 100644 --- a/lms/djangoapps/instructor/services.py +++ b/lms/djangoapps/instructor/services.py @@ -6,7 +6,7 @@ Implementation of "Instructor" service import logging from django.core.exceptions import ObjectDoesNotExist -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, UsageKey diff --git a/lms/djangoapps/instructor_task/views.py b/lms/djangoapps/instructor_task/views.py index e9f678b41f..51e2812577 100644 --- a/lms/djangoapps/instructor_task/views.py +++ b/lms/djangoapps/instructor_task/views.py @@ -5,7 +5,7 @@ import logging from celery.states import FAILURE, READY_STATES, REVOKED from django.http import HttpResponse -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from lms.djangoapps.instructor_task.api_helper import get_status_from_instructor_task, get_updated_instructor_task from lms.djangoapps.instructor_task.models import PROGRESS diff --git a/lms/djangoapps/learner_dashboard/programs.py b/lms/djangoapps/learner_dashboard/programs.py index f69fcb586a..88a68b23d4 100644 --- a/lms/djangoapps/learner_dashboard/programs.py +++ b/lms/djangoapps/learner_dashboard/programs.py @@ -9,7 +9,7 @@ from django.contrib.sites.shortcuts import get_current_site from django.http import Http404 from django.template.loader import render_to_string from django.urls import reverse -from django.utils.translation import ugettext_lazy as _ # lint-amnesty, pylint: disable=unused-import +from django.utils.translation import gettext_lazy as _ # lint-amnesty, pylint: disable=unused-import from web_fragments.fragment import Fragment from common.djangoapps.student.roles import GlobalStaff diff --git a/lms/djangoapps/learner_dashboard/urls.py b/lms/djangoapps/learner_dashboard/urls.py index dff13d82c0..3b1f297e2c 100644 --- a/lms/djangoapps/learner_dashboard/urls.py +++ b/lms/djangoapps/learner_dashboard/urls.py @@ -1,14 +1,14 @@ """Learner dashboard URL routing configuration""" -from django.conf.urls import url +from django.urls import path, re_path from lms.djangoapps.learner_dashboard import programs, views urlpatterns = [ - url(r'^programs/$', views.program_listing, name='program_listing_view'), - url(r'^programs/(?P[0-9a-f-]+)/$', views.program_details, name='program_details_view'), - url(r'^programs_fragment/$', programs.ProgramsFragmentView.as_view(), name='program_listing_fragment_view'), - url(r'^programs/(?P[0-9a-f-]+)/details_fragment/$', programs.ProgramDetailsFragmentView.as_view(), - name='program_details_fragment_view'), + path('programs/', views.program_listing, name='program_listing_view'), + re_path(r'^programs/(?P[0-9a-f-]+)/$', views.program_details, name='program_details_view'), + path('programs_fragment/', programs.ProgramsFragmentView.as_view(), name='program_listing_fragment_view'), + re_path(r'^programs/(?P[0-9a-f-]+)/details_fragment/$', programs.ProgramDetailsFragmentView.as_view(), + name='program_details_fragment_view'), ] diff --git a/lms/djangoapps/lti_provider/urls.py b/lms/djangoapps/lti_provider/urls.py index 5961252560..d3fdd4e78c 100644 --- a/lms/djangoapps/lti_provider/urls.py +++ b/lms/djangoapps/lti_provider/urls.py @@ -4,12 +4,12 @@ LTI Provider API endpoint urls. from django.conf import settings -from django.conf.urls import url +from django.urls import re_path from lms.djangoapps.lti_provider import views urlpatterns = [ - url( + re_path( r'^courses/{course_id}/{usage_id}$'.format( course_id=settings.COURSE_ID_PATTERN, usage_id=settings.USAGE_ID_PATTERN diff --git a/lms/djangoapps/mobile_api/course_info/urls.py b/lms/djangoapps/mobile_api/course_info/urls.py index 00e395581b..5314b43bc5 100644 --- a/lms/djangoapps/mobile_api/course_info/urls.py +++ b/lms/djangoapps/mobile_api/course_info/urls.py @@ -4,20 +4,20 @@ URLs for course_info API from django.conf import settings -from django.conf.urls import url +from django.urls import path, re_path from .views import CourseHandoutsList, CourseUpdatesList, CourseGoalsRecordUserActivity urlpatterns = [ - url( + re_path( fr'^{settings.COURSE_ID_PATTERN}/handouts$', CourseHandoutsList.as_view(), name='course-handouts-list' ), - url( + re_path( fr'^{settings.COURSE_ID_PATTERN}/updates$', CourseUpdatesList.as_view(), name='course-updates-list' ), - url(r'^record_user_activity$', CourseGoalsRecordUserActivity.as_view(), name='record_user_activity'), + path('record_user_activity', CourseGoalsRecordUserActivity.as_view(), name='record_user_activity'), ] diff --git a/lms/djangoapps/mobile_api/middleware.py b/lms/djangoapps/mobile_api/middleware.py index 41af2b688b..d4a2d0adb2 100644 --- a/lms/djangoapps/mobile_api/middleware.py +++ b/lms/djangoapps/mobile_api/middleware.py @@ -91,7 +91,7 @@ class AppVersionUpgrade(MiddlewareMixin): Returns: dict: Containing app version info """ - user_agent = request.META.get('HTTP_USER_AGENT') + user_agent = request.headers.get('User-Agent') if user_agent: platform = self._get_platform(request, user_agent) if platform: diff --git a/lms/djangoapps/mobile_api/urls.py b/lms/djangoapps/mobile_api/urls.py index a6fec8dd97..1ad34ced5d 100644 --- a/lms/djangoapps/mobile_api/urls.py +++ b/lms/djangoapps/mobile_api/urls.py @@ -3,12 +3,12 @@ URLs for mobile API """ -from django.conf.urls import include, url +from django.urls import include, path from .users.views import my_user_info urlpatterns = [ - url(r'^users/', include('lms.djangoapps.mobile_api.users.urls')), - url(r'^my_user_info', my_user_info, name='user-info'), - url(r'^course_info/', include('lms.djangoapps.mobile_api.course_info.urls')), + path('users/', include('lms.djangoapps.mobile_api.users.urls')), + path('my_user_info', my_user_info, name='user-info'), + path('course_info/', include('lms.djangoapps.mobile_api.course_info.urls')), ] diff --git a/lms/djangoapps/mobile_api/users/urls.py b/lms/djangoapps/mobile_api/users/urls.py index 419d9d67f0..266644246e 100644 --- a/lms/djangoapps/mobile_api/users/urls.py +++ b/lms/djangoapps/mobile_api/users/urls.py @@ -4,18 +4,18 @@ URLs for user API from django.conf import settings -from django.conf.urls import url +from django.urls import re_path from .views import UserCourseEnrollmentsList, UserCourseStatus, UserDetail urlpatterns = [ - url('^' + settings.USERNAME_PATTERN + '$', UserDetail.as_view(), name='user-detail'), - url( + re_path('^' + settings.USERNAME_PATTERN + '$', UserDetail.as_view(), name='user-detail'), + re_path( '^' + settings.USERNAME_PATTERN + '/course_enrollments/$', UserCourseEnrollmentsList.as_view(), name='courseenrollment-detail' ), - url(f'^{settings.USERNAME_PATTERN}/course_status_info/{settings.COURSE_ID_PATTERN}', - UserCourseStatus.as_view(), - name='user-course-status') + re_path(f'^{settings.USERNAME_PATTERN}/course_status_info/{settings.COURSE_ID_PATTERN}', + UserCourseStatus.as_view(), + name='user-course-status') ] diff --git a/lms/djangoapps/program_enrollments/models.py b/lms/djangoapps/program_enrollments/models.py index cc9f7cae60..04114a9dd5 100644 --- a/lms/djangoapps/program_enrollments/models.py +++ b/lms/djangoapps/program_enrollments/models.py @@ -6,7 +6,7 @@ from django.conf import settings from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imported-auth-user from django.core.exceptions import ValidationError from django.db import models -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 CourseKeyField from simple_history.models import HistoricalRecords diff --git a/lms/djangoapps/program_enrollments/rest_api/urls.py b/lms/djangoapps/program_enrollments/rest_api/urls.py index 289653f6c7..625184ca9f 100644 --- a/lms/djangoapps/program_enrollments/rest_api/urls.py +++ b/lms/djangoapps/program_enrollments/rest_api/urls.py @@ -3,12 +3,12 @@ Program Enrollment API URLs. """ -from django.conf.urls import include, url +from django.urls import include, path from .v1 import urls as v1_urls app_name = 'lms.djangoapps.program_enrollments' urlpatterns = [ - url(r'^v1/', include(v1_urls)) + path('v1/', include(v1_urls)) ] diff --git a/lms/djangoapps/program_enrollments/rest_api/v1/urls.py b/lms/djangoapps/program_enrollments/rest_api/v1/urls.py index 8889a0dc64..9741dab7be 100644 --- a/lms/djangoapps/program_enrollments/rest_api/v1/urls.py +++ b/lms/djangoapps/program_enrollments/rest_api/v1/urls.py @@ -2,7 +2,7 @@ from django.conf import settings -from django.conf.urls import url +from django.urls import path, re_path from openedx.core.constants import COURSE_ID_PATTERN @@ -20,22 +20,22 @@ from .views import ( app_name = 'v1' urlpatterns = [ - url( - r'^programs/enrollments/$', + path( + 'programs/enrollments/', UserProgramReadOnlyAccessView.as_view(), name='learner_program_enrollments' ), - url( - r'^programs/readonly_access/$', + path( + 'programs/readonly_access/', UserProgramReadOnlyAccessView.as_view(), name='user_program_readonly_access' ), - url( + re_path( fr'^programs/{PROGRAM_UUID_PATTERN}/enrollments/$', ProgramEnrollmentsView.as_view(), name='program_enrollments' ), - url( + re_path( r'^programs/{program_uuid}/courses/{course_id}/enrollments/'.format( program_uuid=PROGRAM_UUID_PATTERN, course_id=COURSE_ID_PATTERN @@ -43,7 +43,7 @@ urlpatterns = [ ProgramCourseEnrollmentsView.as_view(), name="program_course_enrollments" ), - url( + re_path( r'^programs/{program_uuid}/courses/{course_id}/grades/'.format( program_uuid=PROGRAM_UUID_PATTERN, course_id=COURSE_ID_PATTERN @@ -51,14 +51,14 @@ urlpatterns = [ ProgramCourseGradesView.as_view(), name="program_course_grades" ), - url( + re_path( r'^programs/{program_uuid}/overview/'.format( program_uuid=PROGRAM_UUID_PATTERN, ), ProgramCourseEnrollmentOverviewView.as_view(), name="program_course_enrollments_overview" ), - url( + re_path( r'^users/{username}/programs/{program_uuid}/courses'.format( username=settings.USERNAME_PATTERN, program_uuid=PROGRAM_UUID_PATTERN, @@ -66,8 +66,8 @@ urlpatterns = [ UserProgramCourseEnrollmentView.as_view(), name="user_program_course_enrollments" ), - url( - r'^integration-reset', + path( + 'integration-reset', EnrollmentDataResetView.as_view(), name="reset_enrollment_data", ) diff --git a/lms/djangoapps/rss_proxy/urls.py b/lms/djangoapps/rss_proxy/urls.py index c8b2432a94..a18d144a7c 100644 --- a/lms/djangoapps/rss_proxy/urls.py +++ b/lms/djangoapps/rss_proxy/urls.py @@ -3,11 +3,11 @@ URLs for the rss_proxy djangoapp. """ -from django.conf.urls import url +from django.urls import path from .views import proxy app_name = 'rss_proxy' urlpatterns = [ - url(r'^$', proxy, name='proxy'), + path('', proxy, name='proxy'), ] diff --git a/lms/djangoapps/static_template_view/urls.py b/lms/djangoapps/static_template_view/urls.py index a05783085c..c7ecd6992c 100644 --- a/lms/djangoapps/static_template_view/urls.py +++ b/lms/djangoapps/static_template_view/urls.py @@ -4,30 +4,30 @@ URLs for static_template_view app from django.conf import settings -from django.conf.urls import url +from django.urls import path, re_path from lms.djangoapps.static_template_view import views urlpatterns = [ # Semi-static views (these need to be rendered and have the login bar, but don't change) - url(r'^404$', views.render, {'template': '404.html'}, name="404"), + path('404', views.render, {'template': '404.html'}, name="404"), # display error page templates, for testing purposes - url(r'^404$', views.render_404, name='static_template_view.views.render_404'), - url(r'^500$', views.render_500, name='static_template_view.views.render_500'), + path('404', views.render_404, name='static_template_view.views.render_404'), + path('500', views.render_500, name='static_template_view.views.render_500'), - url(r'^blog$', views.render, {'template': 'blog.html'}, name="blog"), - url(r'^contact$', views.render, {'template': 'contact.html'}, name="contact"), - url(r'^donate$', views.render, {'template': 'donate.html'}, name="donate"), - url(r'^faq$', views.render, {'template': 'faq.html'}, name="faq"), - url(r'^help$', views.render, {'template': 'help.html'}, name="help_edx"), - url(r'^jobs$', views.render, {'template': 'jobs.html'}, name="jobs"), - url(r'^news$', views.render, {'template': 'news.html'}, name="news"), - url(r'^press$', views.render, {'template': 'press.html'}, name="press"), - url(r'^media-kit$', views.render, {'template': 'media-kit.html'}, name="media-kit"), - url(r'^copyright$', views.render, {'template': 'copyright.html'}, name="copyright"), + path('blog', views.render, {'template': 'blog.html'}, name="blog"), + path('contact', views.render, {'template': 'contact.html'}, name="contact"), + path('donate', views.render, {'template': 'donate.html'}, name="donate"), + path('faq', views.render, {'template': 'faq.html'}, name="faq"), + path('help', views.render, {'template': 'help.html'}, name="help_edx"), + path('jobs', views.render, {'template': 'jobs.html'}, name="jobs"), + path('news', views.render, {'template': 'news.html'}, name="news"), + path('press', views.render, {'template': 'press.html'}, name="press"), + path('media-kit', views.render, {'template': 'media-kit.html'}, name="media-kit"), + path('copyright', views.render, {'template': 'copyright.html'}, name="copyright"), # Press releases - url(r'^press/([_a-zA-Z0-9-]+)$', views.render_press_release, name='press_release'), + re_path(r'^press/([_a-zA-Z0-9-]+)$', views.render_press_release, name='press_release'), ] # Only enable URLs for those marketing links actually enabled in the @@ -50,4 +50,4 @@ for key, value in settings.MKTG_URL_LINK_MAP.items(): # Make the assumption that the URL we want is the lowercased # version of the map key - urlpatterns.append(url(r'^%s$' % key.lower(), views.render, {'template': template}, name=value)) + urlpatterns.append(re_path(r'^%s$' % key.lower(), views.render, {'template': template}, name=value)) diff --git a/lms/djangoapps/support/urls.py b/lms/djangoapps/support/urls.py index 6c101bffcf..d9f05d4081 100644 --- a/lms/djangoapps/support/urls.py +++ b/lms/djangoapps/support/urls.py @@ -3,7 +3,7 @@ URLs for the student support app. """ from django.conf import settings -from django.conf.urls import url +from django.urls import path, re_path from .views.certificate import CertificatesSupportView from .views.contact_us import ContactUsView @@ -19,37 +19,38 @@ COURSE_ENTITLEMENTS_VIEW = EntitlementSupportView.as_view() app_name = 'support' urlpatterns = [ - url(r'^$', index, name="index"), - url(r'^certificates/?$', CertificatesSupportView.as_view(), name="certificates"), - url(r'^enrollment/?$', EnrollmentSupportView.as_view(), name="enrollment"), - url(r'^course_entitlement/?$', COURSE_ENTITLEMENTS_VIEW, name="course_entitlement"), - url(r'^contact_us/?$', ContactUsView.as_view(), name="contact_us"), - url( + path('', index, name="index"), + re_path(r'^certificates/?$', CertificatesSupportView.as_view(), name="certificates"), + re_path(r'^enrollment/?$', EnrollmentSupportView.as_view(), name="enrollment"), + re_path(r'^course_entitlement/?$', COURSE_ENTITLEMENTS_VIEW, name="course_entitlement"), + re_path(r'^contact_us/?$', ContactUsView.as_view(), name="contact_us"), + re_path( r'^enrollment/(?P[\w.@+-]+)?$', EnrollmentSupportListView.as_view(), name="enrollment_list" ), - url(r'^manage_user/?$', ManageUserSupportView.as_view(), name="manage_user"), - url( + re_path(r'^manage_user/?$', ManageUserSupportView.as_view(), name="manage_user"), + re_path( r'^manage_user/(?P[\w.@+-]+)?$', ManageUserDetailView.as_view(), name="manage_user_detail" ), - url( + re_path( r'^feature_based_enrollments/?$', FeatureBasedEnrollmentsSupportView.as_view(), name="feature_based_enrollments" ), - url( + re_path( fr'^feature_based_enrollment_details/{settings.COURSE_ID_PATTERN}$', FeatureBasedEnrollmentSupportAPIView.as_view(), name="feature_based_enrollment_details" ), - url(r'link_program_enrollments/?$', LinkProgramEnrollmentSupportView.as_view(), name='link_program_enrollments'), - url( + re_path(r'link_program_enrollments/?$', LinkProgramEnrollmentSupportView.as_view(), + name='link_program_enrollments'), + re_path( r'program_enrollments_inspector/?$', ProgramEnrollmentsInspectorView.as_view(), name='program_enrollments_inspector' ), - url(r'sso_records/(?P[\w.@+-]+)?$', SsoView.as_view(), name='sso_records'), + re_path(r'sso_records/(?P[\w.@+-]+)?$', SsoView.as_view(), name='sso_records'), ] diff --git a/lms/djangoapps/support/views/index.py b/lms/djangoapps/support/views/index.py index 3f949746d0..a4728183b6 100644 --- a/lms/djangoapps/support/views/index.py +++ b/lms/djangoapps/support/views/index.py @@ -4,7 +4,7 @@ Index view for the support app. from django.urls import reverse_lazy -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from common.djangoapps.edxmako.shortcuts import render_to_response from lms.djangoapps.support.decorators import require_support_permission diff --git a/lms/djangoapps/support/views/manage_user.py b/lms/djangoapps/support/views/manage_user.py index a917bc3f41..fdc4f412e3 100644 --- a/lms/djangoapps/support/views/manage_user.py +++ b/lms/djangoapps/support/views/manage_user.py @@ -7,7 +7,7 @@ from django.contrib.auth import get_user_model from django.db.models import Q 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.generic import View from rest_framework.generics import GenericAPIView diff --git a/lms/djangoapps/survey/urls.py b/lms/djangoapps/survey/urls.py index e397f0d18b..7ba0b13826 100644 --- a/lms/djangoapps/survey/urls.py +++ b/lms/djangoapps/survey/urls.py @@ -3,11 +3,11 @@ URL mappings for the Survey feature """ -from django.conf.urls import url +from django.urls import re_path from lms.djangoapps.survey import views urlpatterns = [ - url(r'^(?P[0-9A-Za-z]+)/$', views.view_survey, name='view_survey'), - url(r'^(?P[0-9A-Za-z]+)/answers/$', views.submit_answers, name='submit_answers'), + re_path(r'^(?P[0-9A-Za-z]+)/$', views.view_survey, name='view_survey'), + re_path(r'^(?P[0-9A-Za-z]+)/answers/$', views.submit_answers, name='submit_answers'), ] diff --git a/lms/djangoapps/survey/utils.py b/lms/djangoapps/survey/utils.py index d36f0cc9a9..2f3d2f1483 100644 --- a/lms/djangoapps/survey/utils.py +++ b/lms/djangoapps/survey/utils.py @@ -2,7 +2,7 @@ Utilities for determining whether or not a survey needs to be completed. """ -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from lms.djangoapps.courseware.access import has_access from lms.djangoapps.courseware.access_response import AccessError