diff --git a/registrar/apps/api/internal/urls.py b/registrar/apps/api/internal/urls.py index 34332f3e5..6a215fbcf 100644 --- a/registrar/apps/api/internal/urls.py +++ b/registrar/apps/api/internal/urls.py @@ -1,6 +1,6 @@ """ API internal URLs. """ -from django.conf.urls import url +from django.urls import re_path from registrar.apps.core.constants import PROGRAM_KEY_PATTERN @@ -10,12 +10,12 @@ app_name = 'internal' urlpatterns = [ - url( + re_path( r'^cache/?$', views.FlushProgramCacheView.as_view(), name="flush-program-cache-all", ), - url( + re_path( fr'^cache/{PROGRAM_KEY_PATTERN}/?$', views.FlushProgramCacheView.as_view(), name="flush-program-cache-one", diff --git a/registrar/apps/api/urls.py b/registrar/apps/api/urls.py index 6531e781b..ef87e0c38 100644 --- a/registrar/apps/api/urls.py +++ b/registrar/apps/api/urls.py @@ -4,7 +4,7 @@ All API URLs should be versioned, so urlpatterns should only contain namespaces for the active versions of the API. """ -from django.conf.urls import include, url +from django.urls import include, path from .internal import urls as internal_urls from .v1 import urls as v1_urls @@ -14,8 +14,8 @@ app_name = 'api' urlpatterns = [ - url(r'^internal/', include(internal_urls)), - url(r'^v1/', include(v1_urls)), - url(r'^v2/', include(v2_urls)), - url(r'^v3/', include(v3_urls)), + path('internal/', include(internal_urls)), + path('v1/', include(v1_urls)), + path('v2/', include(v2_urls)), + path('v3/', include(v3_urls)), ] diff --git a/registrar/apps/api/v1/urls.py b/registrar/apps/api/v1/urls.py index 50c799343..e0a3fa165 100644 --- a/registrar/apps/api/v1/urls.py +++ b/registrar/apps/api/v1/urls.py @@ -1,6 +1,6 @@ """ API v1 URLs. """ -from django.conf.urls import url +from django.urls import re_path from registrar.apps.core.constants import ( COURSE_ID_PATTERN, @@ -14,66 +14,66 @@ app_name = 'v1' urlpatterns = [ - url( + re_path( r'^programs/?$', views.ProgramListView.as_view(), name="program-list", ), - url( + re_path( fr'^programs/{PROGRAM_KEY_PATTERN}/?$', views.ProgramRetrieveView.as_view(), name="program", ), - url( + re_path( fr'^programs/{PROGRAM_KEY_PATTERN}/enrollments/?$', views.ProgramEnrollmentView.as_view(), name="program-enrollments", ), - url( + re_path( fr'^programs/{PROGRAM_KEY_PATTERN}/courses/?$', views.ProgramCourseListView.as_view(), name="program-course-list", ), - url( + re_path( fr'^programs/{PROGRAM_KEY_PATTERN}/enrollments/?$', views.ProgramEnrollmentView.as_view(), name="program-enrollment", ), - url( + re_path( fr'^programs/{PROGRAM_KEY_PATTERN}/courses/{COURSE_ID_PATTERN}/grades/?$', views.CourseGradesView.as_view(), name="program-course-grades", ), - url( + re_path( fr'^programs/{PROGRAM_KEY_PATTERN}/courses/{COURSE_ID_PATTERN}/enrollments/?$', views.CourseEnrollmentView.as_view(), name="program-course-enrollment", ), - url( + re_path( fr'^programs/{PROGRAM_KEY_PATTERN}/enrollments/upload/?$', views.ProgramEnrollmentUploadView.as_view(), name="program-enrollment-upload" ), - url( + re_path( fr'^programs/{PROGRAM_KEY_PATTERN}/course_enrollments/upload/?$', views.CourseRunEnrollmentUploadView.as_view(), name="program-course-enrollment-upload" ), - url( + re_path( fr'^programs/{PROGRAM_KEY_PATTERN}/course_enrollments/?$', views.CourseRunEnrollmentDownloadView.as_view(), name="program-course-enrollment-download" ), - url( + re_path( fr'^programs/{PROGRAM_KEY_PATTERN}/reports', views.ReportsListView.as_view(), ), - url( + re_path( r'^jobs/?$', views.JobStatusListView.as_view(), name="job-status-list", ), - url( + re_path( fr'^jobs/{JOB_ID_PATTERN}/?$', views.JobStatusRetrieveView.as_view(), name="job-status", diff --git a/registrar/apps/api/v3/urls.py b/registrar/apps/api/v3/urls.py index 710f2f26e..2f6d2a0e7 100644 --- a/registrar/apps/api/v3/urls.py +++ b/registrar/apps/api/v3/urls.py @@ -1,6 +1,6 @@ """ API v3 URLs. """ -from django.conf.urls import url +from django.urls import re_path from . import views @@ -8,7 +8,7 @@ app_name = 'v3' urlpatterns = [ - url( + re_path( r'^programs/?$', views.ProgramListPaginationView.as_view(), name="program-list", diff --git a/registrar/apps/core/admin.py b/registrar/apps/core/admin.py index 5440ce8e5..a5c5c16dd 100644 --- a/registrar/apps/core/admin.py +++ b/registrar/apps/core/admin.py @@ -2,7 +2,7 @@ from django.contrib import admin from django.contrib.auth.admin import UserAdmin -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from guardian.admin import GuardedModelAdmin from .models import ( diff --git a/registrar/apps/core/models.py b/registrar/apps/core/models.py index eeb6a0875..10dfe3e4b 100644 --- a/registrar/apps/core/models.py +++ b/registrar/apps/core/models.py @@ -3,7 +3,7 @@ from django.contrib.auth.models import AbstractUser, Group from django.db import models from django.utils.functional import cached_property -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from guardian.shortcuts import remove_perm from model_utils.models import TimeStampedModel diff --git a/registrar/urls.py b/registrar/urls.py index d821c517b..b9c41171c 100644 --- a/registrar/urls.py +++ b/registrar/urls.py @@ -18,9 +18,9 @@ from auth_backends.urls import oauth2_urlpatterns from django.conf import settings -from django.conf.urls import include, url from django.conf.urls.static import static from django.contrib import admin +from django.urls import include, path, re_path from django.views.generic.base import RedirectView from edx_api_doc_tools import make_api_info, make_docs_ui_view @@ -46,40 +46,40 @@ email="masters-dev@edx.org", description=api_description_file.read(), ), - api_url_patterns=[url(r'^api/v2/', include(v2_urls))], + api_url_patterns=[path('api/v2/', include(v2_urls))], ) urlpatterns = oauth2_urlpatterns + [ # '/' and '/login' redirect to '/login/', # which attempts LMS OAuth and then redirects to api-docs. - url(r'^/?$', RedirectView.as_view(url=settings.LOGIN_URL)), - url(r'^login$', RedirectView.as_view(url=settings.LOGIN_URL)), + re_path(r'^/?$', RedirectView.as_view(url=settings.LOGIN_URL)), + path('login', RedirectView.as_view(url=settings.LOGIN_URL)), # Use the same auth views for all logins, # including those originating from the browseable API. - url(r'^api-auth/', include(oauth2_urlpatterns)), + path('api-auth/', include(oauth2_urlpatterns)), # NEW Swagger documentation UI, generated using edx-api-doc-tools. - url(r'^api-docs$', RedirectView.as_view(pattern_name='api-docs-new')), - url(r'^api-docs/$', new_api_ui_view, name='api-docs-new'), + path('api-docs', RedirectView.as_view(pattern_name='api-docs-new')), + path('api-docs/', new_api_ui_view, name='api-docs-new'), # Django admin panel. - url(r'^admin$', RedirectView.as_view(pattern_name='admin:index')), - url(r'^admin/', admin.site.urls), + path('admin', RedirectView.as_view(pattern_name='admin:index')), + re_path(r'^admin/', admin.site.urls), # Health view. - url(r'^health/?$', core_views.health, name='health'), + re_path(r'^health/?$', core_views.health, name='health'), # Auto-auth for testing. View raises 404 if not `settings.ENABLE_AUTO_AUTH` - url(r'^auto_auth/?$', core_views.AutoAuth.as_view(), name='auto_auth'), + re_path(r'^auto_auth/?$', core_views.AutoAuth.as_view(), name='auto_auth'), # The API itself! - url(r'^api/', include(api_urls)), + path('api/', include(api_urls)), ] # edx-drf-extensions csrf app urlpatterns += [ - url(r'', include('csrf.urls')), + path('', include('csrf.urls')), ] if settings.DEBUG and os.environ.get('ENABLE_DJANGO_TOOLBAR', False): # pragma: no cover @@ -90,7 +90,7 @@ "ENABLE_DJANGO_TOOLBAR is true, but debug_toolbar could not be imported." ) else: - urlpatterns.append(url(r'^__debug__/', include(debug_toolbar.urls))) + urlpatterns.append(path('__debug__/', include(debug_toolbar.urls))) if settings.DEBUG: # pragma: no cover urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)