From bd5e00b72524565b0fe0a2b5a6c20e317a890bef Mon Sep 17 00:00:00 2001 From: Jawayria Date: Mon, 13 Dec 2021 17:13:57 +0500 Subject: [PATCH] fix: fixed RemovedInDjango40 warnings in common --- .../djangoapps/course_modes/rest_api/urls.py | 5 +++-- .../course_modes/rest_api/v1/urls.py | 6 +++--- common/djangoapps/course_modes/urls.py | 10 ++++----- .../djangoapps/entitlements/rest_api/urls.py | 5 +++-- .../entitlements/rest_api/v1/urls.py | 7 ++++--- common/djangoapps/student/urls.py | 20 +++++++++--------- .../djangoapps/third_party_auth/api/urls.py | 13 ++++++------ common/djangoapps/third_party_auth/urls.py | 21 ++++++++++--------- common/djangoapps/track/urls.py | 6 +++--- common/djangoapps/util/date_utils.py | 2 +- common/lib/capa/capa/safe_exec/remote_exec.py | 2 +- 11 files changed, 50 insertions(+), 47 deletions(-) diff --git a/common/djangoapps/course_modes/rest_api/urls.py b/common/djangoapps/course_modes/rest_api/urls.py index 9bcba6ec2f..ae31164e07 100644 --- a/common/djangoapps/course_modes/rest_api/urls.py +++ b/common/djangoapps/course_modes/rest_api/urls.py @@ -3,10 +3,11 @@ URL definitions for the course_modes API. """ -from django.conf.urls import include, url +from django.conf.urls import include +from django.urls import path app_name = 'common.djangoapps.course_modes.rest_api' urlpatterns = [ - url(r'^v1/', include('common.djangoapps.course_modes.rest_api.v1.urls', namespace='v1')), + path('v1/', include('common.djangoapps.course_modes.rest_api.v1.urls', namespace='v1')), ] diff --git a/common/djangoapps/course_modes/rest_api/v1/urls.py b/common/djangoapps/course_modes/rest_api/v1/urls.py index 6102699840..6ec5e004a1 100644 --- a/common/djangoapps/course_modes/rest_api/v1/urls.py +++ b/common/djangoapps/course_modes/rest_api/v1/urls.py @@ -4,19 +4,19 @@ URL definitions for the course_modes v1 API. from django.conf import settings -from django.conf.urls import url from common.djangoapps.course_modes.rest_api.v1 import views +from django.urls import re_path app_name = 'v1' urlpatterns = [ - url( + re_path( fr'^courses/{settings.COURSE_ID_PATTERN}/$', views.CourseModesView.as_view(), name='course_modes_list' ), - url( + re_path( fr'^courses/{settings.COURSE_ID_PATTERN}/(?P.*)$', views.CourseModesDetailView.as_view(), name='course_modes_detail' diff --git a/common/djangoapps/course_modes/urls.py b/common/djangoapps/course_modes/urls.py index 6337f51943..91cf3e466f 100644 --- a/common/djangoapps/course_modes/urls.py +++ b/common/djangoapps/course_modes/urls.py @@ -2,18 +2,18 @@ from django.conf import settings -from django.conf.urls import url from common.djangoapps.course_modes import views +from django.urls import re_path urlpatterns = [ - url(fr'^choose/{settings.COURSE_ID_PATTERN}/$', views.ChooseModeView.as_view(), name='course_modes_choose'), + re_path(fr'^choose/{settings.COURSE_ID_PATTERN}/$', views.ChooseModeView.as_view(), name='course_modes_choose'), ] # Enable verified mode creation if settings.FEATURES.get('MODE_CREATION_FOR_TESTING'): urlpatterns.append( - url(fr'^create_mode/{settings.COURSE_ID_PATTERN}/$', - views.create_mode, - name='create_mode'), + re_path(fr'^create_mode/{settings.COURSE_ID_PATTERN}/$', + views.create_mode, + name='create_mode'), ) diff --git a/common/djangoapps/entitlements/rest_api/urls.py b/common/djangoapps/entitlements/rest_api/urls.py index 18bafa5679..8c3bfaee22 100644 --- a/common/djangoapps/entitlements/rest_api/urls.py +++ b/common/djangoapps/entitlements/rest_api/urls.py @@ -2,9 +2,10 @@ URLs file for the Entitlements API. """ -from django.conf.urls import include, url +from django.conf.urls import include +from django.urls import path app_name = 'entitlements' urlpatterns = [ - url(r'^v1/', include('common.djangoapps.entitlements.rest_api.v1.urls')), + path('v1/', include('common.djangoapps.entitlements.rest_api.v1.urls')), ] diff --git a/common/djangoapps/entitlements/rest_api/v1/urls.py b/common/djangoapps/entitlements/rest_api/v1/urls.py index b7758db74e..5befc2a5c9 100644 --- a/common/djangoapps/entitlements/rest_api/v1/urls.py +++ b/common/djangoapps/entitlements/rest_api/v1/urls.py @@ -2,10 +2,11 @@ URLs for the V1 of the Entitlements API. """ -from django.conf.urls import include, url +from django.conf.urls import include from rest_framework.routers import DefaultRouter from .views import EntitlementEnrollmentViewSet, EntitlementViewSet +from django.urls import path, re_path router = DefaultRouter() router.register(r'entitlements', EntitlementViewSet, basename='entitlements') @@ -17,8 +18,8 @@ ENROLLMENTS_VIEW = EntitlementEnrollmentViewSet.as_view({ app_name = 'v1' urlpatterns = [ - url(r'', include(router.urls)), - url( + path('', include(router.urls)), + re_path( fr'entitlements/(?P{EntitlementViewSet.ENTITLEMENT_UUID4_REGEX})/enrollments$', ENROLLMENTS_VIEW, name='enrollments' diff --git a/common/djangoapps/student/urls.py b/common/djangoapps/student/urls.py index aafac7b1dd..a82ec29399 100644 --- a/common/djangoapps/student/urls.py +++ b/common/djangoapps/student/urls.py @@ -4,26 +4,26 @@ URLs for student app from django.conf import settings -from django.conf.urls import url from . import views +from django.urls import path, re_path urlpatterns = [ - url(r'^email_confirm/(?P[^/]*)$', views.confirm_email_change, name='confirm_email_change'), + re_path(r'^email_confirm/(?P[^/]*)$', views.confirm_email_change, name='confirm_email_change'), - url(r'^activate/(?P[^/]*)$', views.activate_account, name="activate"), + re_path(r'^activate/(?P[^/]*)$', views.activate_account, name="activate"), - url(r'^accounts/disable_account_ajax$', views.disable_account_ajax, name="disable_account_ajax"), - url(r'^accounts/manage_user_standing', views.manage_user_standing, name='manage_user_standing'), + path('accounts/disable_account_ajax', views.disable_account_ajax, name="disable_account_ajax"), + path('accounts/manage_user_standing', views.manage_user_standing, name='manage_user_standing'), - url(r'^change_email_settings$', views.change_email_settings, name='change_email_settings'), + path('change_email_settings', views.change_email_settings, name='change_email_settings'), - url(fr'^course_run/{settings.COURSE_ID_PATTERN}/refund_status$', - views.course_run_refund_status, - name="course_run_refund_status"), + re_path(fr'^course_run/{settings.COURSE_ID_PATTERN}/refund_status$', + views.course_run_refund_status, + name="course_run_refund_status"), - url( + re_path( r'^activate_secondary_email/(?P[^/]*)$', views.activate_secondary_email, name='activate_secondary_email' diff --git a/common/djangoapps/third_party_auth/api/urls.py b/common/djangoapps/third_party_auth/api/urls.py index bca2f7bbb0..361c7097f0 100644 --- a/common/djangoapps/third_party_auth/api/urls.py +++ b/common/djangoapps/third_party_auth/api/urls.py @@ -2,27 +2,26 @@ from django.conf import settings -from django.conf.urls import url from .views import ThirdPartyAuthUserStatusView, UserMappingView, UserView, UserViewV2 +from django.urls import path, re_path PROVIDER_PATTERN = r'(?P[\w.+-]+)(?:\:(?P[\w.+-]+))?' urlpatterns = [ - url( + re_path( fr'^v0/users/{settings.USERNAME_PATTERN}$', UserView.as_view(), name='third_party_auth_users_api', ), - url(r'^v0/users/', UserViewV2.as_view(), name='third_party_auth_users_api_v2'), - url( + path('v0/users/', UserViewV2.as_view(), name='third_party_auth_users_api_v2'), + re_path( fr'^v0/providers/{PROVIDER_PATTERN}/users$', UserMappingView.as_view(), name='third_party_auth_user_mapping_api', ), - url( - r'^v0/providers/user_status$', - ThirdPartyAuthUserStatusView.as_view(), + path( + 'v0/providers/user_status', ThirdPartyAuthUserStatusView.as_view(), name='third_party_auth_user_status_api', ), ] diff --git a/common/djangoapps/third_party_auth/urls.py b/common/djangoapps/third_party_auth/urls.py index 4a90ef174f..e923637dc0 100644 --- a/common/djangoapps/third_party_auth/urls.py +++ b/common/djangoapps/third_party_auth/urls.py @@ -1,6 +1,6 @@ """Url configuration for the auth module.""" -from django.conf.urls import include, url +from django.conf.urls import include from .views import ( IdPRedirectView, @@ -9,15 +9,16 @@ from .views import ( post_to_custom_auth_form, saml_metadata_view ) +from django.urls import path, re_path urlpatterns = [ - url(r'^auth/inactive', inactive_user_view, name="third_party_inactive_redirect"), - url(r'^auth/custom_auth_entry', post_to_custom_auth_form, name='tpa_post_to_custom_auth_form'), - url(r'^auth/saml/metadata.xml', saml_metadata_view), - url(r'^auth/login/(?Plti)/$', lti_login_and_complete_view), - url(r'^auth/idp_redirect/(?P[\w-]+)', IdPRedirectView.as_view(), name="idp_redirect"), - url(r'^auth/', include('social_django.urls', namespace='social')), - url(r'^auth/saml/v0/', include('common.djangoapps.third_party_auth.samlproviderconfig.urls')), - url(r'^auth/saml/v0/', include('common.djangoapps.third_party_auth.samlproviderdata.urls')), - url(r'^auth/saml/v0/', include('common.djangoapps.third_party_auth.saml_configuration.urls')), + path('auth/inactive', inactive_user_view, name="third_party_inactive_redirect"), + path('auth/custom_auth_entry', post_to_custom_auth_form, name='tpa_post_to_custom_auth_form'), + re_path(r'^auth/saml/metadata.xml', saml_metadata_view), + re_path(r'^auth/login/(?Plti)/$', lti_login_and_complete_view), + path('auth/idp_redirect/', IdPRedirectView.as_view(), name="idp_redirect"), + path('auth/', include('social_django.urls', namespace='social')), + path('auth/saml/v0/', include('common.djangoapps.third_party_auth.samlproviderconfig.urls')), + path('auth/saml/v0/', include('common.djangoapps.third_party_auth.samlproviderdata.urls')), + path('auth/saml/v0/', include('common.djangoapps.third_party_auth.saml_configuration.urls')), ] diff --git a/common/djangoapps/track/urls.py b/common/djangoapps/track/urls.py index ed7877f252..ac43112a56 100644 --- a/common/djangoapps/track/urls.py +++ b/common/djangoapps/track/urls.py @@ -1,12 +1,12 @@ """ URLs for track app """ -from django.conf.urls import url from . import views from .views import segmentio +from django.urls import path urlpatterns = [ - url(r'^event$', views.user_track), - url(r'^segmentio/event$', segmentio.segmentio_event), + path('event', views.user_track), + path('segmentio/event', segmentio.segmentio_event), ] diff --git a/common/djangoapps/util/date_utils.py b/common/djangoapps/util/date_utils.py index db7f2fe279..968fb55d7c 100644 --- a/common/djangoapps/util/date_utils.py +++ b/common/djangoapps/util/date_utils.py @@ -7,7 +7,7 @@ import re from datetime import datetime, timedelta import crum -from django.utils.translation import get_language, pgettext, gettext +from django.utils.translation import get_language, gettext, pgettext from pytz import UnknownTimeZoneError, timezone, utc from lms.djangoapps.courseware.context_processor import user_timezone_locale_prefs diff --git a/common/lib/capa/capa/safe_exec/remote_exec.py b/common/lib/capa/capa/safe_exec/remote_exec.py index 7f13e0fbd3..8baf0b7108 100644 --- a/common/lib/capa/capa/safe_exec/remote_exec.py +++ b/common/lib/capa/capa/safe_exec/remote_exec.py @@ -8,13 +8,13 @@ import logging from codejail.safe_exec import SafeExecException from django.conf import settings -from django.utils.translation import ugettext as _ from edx_toggles.toggles import SettingToggle from importlib import import_module from requests.exceptions import RequestException, HTTPError from simplejson import JSONDecodeError from .exceptions import CodejailServiceParseError, CodejailServiceStatusError, CodejailServiceUnavailable +from django.utils.translation import gettext as _ log = logging.getLogger(__name__)