From d62def6d6b1b7d94e520567f7b58f2a65e181f71 Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Tue, 22 Dec 2020 23:07:33 +0100 Subject: [PATCH] django.conf.urls is deprecated and will be removed in Django 4.0, use django.urls.re_path instead MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Yohann D'ANELLO Signed-off-by: Yohann D'ANELLO --- cas_server/tests/urls.py | 14 ++++++++++++-- cas_server/urls.py | 35 +++++++++++++++++++++++------------ 2 files changed, 35 insertions(+), 14 deletions(-) diff --git a/cas_server/tests/urls.py b/cas_server/tests/urls.py index a9ed25c..b95c228 100644 --- a/cas_server/tests/urls.py +++ b/cas_server/tests/urls.py @@ -13,10 +13,20 @@ Including another URLconf 1. Import the include() function: from django.conf.urls import url, include, include 2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls')) """ + +import django + +if django.VERSION < (2,): + from django.conf.urls import url + re_path = url +else: + from django.urls import re_path + + from django.conf.urls import url, include from django.contrib import admin urlpatterns = [ - url(r'^admin/', admin.site.urls), - url(r'^', include('cas_server.urls', namespace='cas_server')), + re_path(r'^admin/', admin.site.urls), + re_path(r'^', include('cas_server.urls', namespace='cas_server')), ] diff --git a/cas_server/urls.py b/cas_server/urls.py index 1e874c0..680c61e 100644 --- a/cas_server/urls.py +++ b/cas_server/urls.py @@ -10,6 +10,16 @@ # # (c) 2015-2016 Valentin Samir """urls for the app""" + +import django + +if django.VERSION < (2,): + from django.conf.urls import url + re_path = url +else: + from django.urls import re_path + + from django.conf.urls import url from django.views.generic import RedirectView from django.views.decorators.debug import sensitive_post_parameters, sensitive_variables @@ -19,42 +29,42 @@ from cas_server import views app_name = "cas_server" urlpatterns = [ - url( + re_path( r'^$', RedirectView.as_view(pattern_name="cas_server:login", permanent=False, query_string=True) ), - url( + re_path( '^login$', sensitive_post_parameters('password')( views.LoginView.as_view() ), name='login' ), - url('^logout$', views.LogoutView.as_view(), name='logout'), - url('^validate$', views.Validate.as_view(), name='validate'), - url( + re_path('^logout$', views.LogoutView.as_view(), name='logout'), + re_path('^validate$', views.Validate.as_view(), name='validate'), + re_path( '^serviceValidate$', views.ValidateService.as_view(allow_proxy_ticket=False), name='serviceValidate' ), - url( + re_path( '^proxyValidate$', views.ValidateService.as_view(allow_proxy_ticket=True), name='proxyValidate' ), - url('^proxy$', views.Proxy.as_view(), name='proxy'), - url( + re_path('^proxy$', views.Proxy.as_view(), name='proxy'), + re_path( '^p3/serviceValidate$', views.ValidateService.as_view(allow_proxy_ticket=False), name='p3_serviceValidate' ), - url( + re_path( '^p3/proxyValidate$', views.ValidateService.as_view(allow_proxy_ticket=True), name='p3_proxyValidate' ), - url('^samlValidate$', views.SamlValidate.as_view(), name='samlValidate'), - url( + re_path('^samlValidate$', views.SamlValidate.as_view(), name='samlValidate'), + re_path( '^auth$', sensitive_variables('password', 'secret')( sensitive_post_parameters('password', 'secret')( @@ -63,5 +73,6 @@ urlpatterns = [ ), name='auth' ), - url("^federate(?:/(?P([^/]+)))?$", views.FederateAuth.as_view(), name='federateAuth'), + re_path("^federate(?:/(?P([^/]+)))?$", + views.FederateAuth.as_view(), name='federateAuth'), ]