From d8786aae95d62975eb46e44f52c6e98485df3b1a Mon Sep 17 00:00:00 2001 From: Agate Berriot Date: Wed, 31 Aug 2022 09:32:39 +0200 Subject: [PATCH] django4: fix urls deprecation warnings (#68573) --- welco/apps.py | 6 ++-- welco/sources/counter/urls.py | 4 +-- welco/sources/mail/urls.py | 18 +++++----- welco/sources/phone/urls.py | 14 ++++---- welco/urls.py | 62 +++++++++++++++++------------------ 5 files changed, 52 insertions(+), 52 deletions(-) diff --git a/welco/apps.py b/welco/apps.py index 6a6c832..ac43808 100644 --- a/welco/apps.py +++ b/welco/apps.py @@ -15,7 +15,7 @@ # along with this program. If not, see . from django.apps import apps -from django.conf.urls import include, url +from django.urls import include, re_path def register_urls(urlpatterns): @@ -25,9 +25,9 @@ def register_urls(urlpatterns): if hasattr(app, 'get_before_urls'): urls = app.get_before_urls() if urls: - pre_urls.append(url('^', include(urls))) + pre_urls.append(re_path('^', include(urls))) if hasattr(app, 'get_after_urls'): urls = app.get_after_urls() if urls: - post_urls.append(url('^', include(urls))) + post_urls.append(re_path('^', include(urls))) return pre_urls + urlpatterns + post_urls diff --git a/welco/sources/counter/urls.py b/welco/sources/counter/urls.py index f9a9d04..db27026 100644 --- a/welco/sources/counter/urls.py +++ b/welco/sources/counter/urls.py @@ -14,10 +14,10 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -from django.conf.urls import url +from django.urls import path from . import views urlpatterns = [ - url(r'^ajax/counter/zone/$', views.zone, name='counter-zone'), + path('ajax/counter/zone/', views.zone, name='counter-zone'), ] diff --git a/welco/sources/mail/urls.py b/welco/sources/mail/urls.py index a12c355..db95ce6 100644 --- a/welco/sources/mail/urls.py +++ b/welco/sources/mail/urls.py @@ -14,17 +14,17 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -from django.conf.urls import url +from django.urls import path, re_path from .views import edit_note, feeder, mail_count, mail_response, note, qualification_save, reject, viewer urlpatterns = [ - url(r'^mail/viewer/$', viewer, name='mail-viewer'), - url(r'^mail/feeder/$', feeder, name='mail-feeder'), - url(r'^ajax/mail/reject$', reject, name='mail-reject'), - url(r'^ajax/qualification-mail-save$', qualification_save, name='qualif-mail-save'), - url(r'^ajax/mail/edit-note/$', edit_note, name='mail-edit-note'), - url(r'^ajax/mail/note/(?P\w+)$', note, name='mail-note'), - url(r'^ajax/count/mail/$', mail_count, name='mail-count'), - url(r'^api/mail/response/$', mail_response, name='mail-api-response'), + path('mail/viewer/', viewer, name='mail-viewer'), + path('mail/feeder/', feeder, name='mail-feeder'), + path('ajax/mail/reject', reject, name='mail-reject'), + path('ajax/qualification-mail-save', qualification_save, name='qualif-mail-save'), + path('ajax/mail/edit-note/', edit_note, name='mail-edit-note'), + re_path(r'^ajax/mail/note/(?P\w+)$', note, name='mail-note'), + path('ajax/count/mail/', mail_count, name='mail-count'), + path('api/mail/response/', mail_response, name='mail-api-response'), ] diff --git a/welco/sources/phone/urls.py b/welco/sources/phone/urls.py index ad16b9c..bb62798 100644 --- a/welco/sources/phone/urls.py +++ b/welco/sources/phone/urls.py @@ -14,15 +14,15 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -from django.conf.urls import url +from django.urls import path, re_path from . import views urlpatterns = [ - url(r'^ajax/phone/zone/$', views.zone, name='phone-zone'), - url(r'^api/phone/call-event/$', views.call_event, name='phone-call-event'), - url(r'^api/phone/active-call/(?P\w+)/$', views.active_call, name='phone-active-call'), - url(r'^api/phone/current-calls/$', views.current_calls, name='phone-current-calls'), - url(r'^api/phone/take-line/$', views.take_line, name='phone-take-line'), - url(r'^api/phone/release-line/$', views.release_line, name='phone-release-line'), + path('ajax/phone/zone/', views.zone, name='phone-zone'), + path('api/phone/call-event/', views.call_event, name='phone-call-event'), + re_path(r'^api/phone/active-call/(?P\w+)/$', views.active_call, name='phone-active-call'), + path('api/phone/current-calls/', views.current_calls, name='phone-current-calls'), + path('api/phone/take-line/', views.take_line, name='phone-take-line'), + path('api/phone/release-line/', views.release_line, name='phone-release-line'), ] diff --git a/welco/urls.py b/welco/urls.py index db0400e..8128bfc 100644 --- a/welco/urls.py +++ b/welco/urls.py @@ -16,10 +16,10 @@ from ckeditor import views as ckeditor_views 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.contrib.staticfiles.urls import staticfiles_urlpatterns +from django.urls import include, path, re_path from django.views.decorators.cache import never_cache import welco.contacts.views @@ -30,53 +30,53 @@ from . import apps from .kb.views import kb_manager_required urlpatterns = [ - url(r'^$', welco.views.home, name='home'), - url(r'^mail/$', welco.views.home_mail, name='home-mail'), - url(r'^phone/$', welco.views.home_phone, name='home-phone'), - url(r'^counter/$', welco.views.home_counter, name='home-counter'), - url(r'^', include('welco.sources.phone.urls')), - url(r'^', include('welco.sources.counter.urls')), - url(r'^ajax/qualification$', welco.views.qualification, name='qualif-zone'), - url( + path('', welco.views.home, name='home'), + path('mail/', welco.views.home_mail, name='home-mail'), + path('phone/', welco.views.home_phone, name='home-phone'), + path('counter/', welco.views.home_counter, name='home-counter'), + re_path(r'^', include('welco.sources.phone.urls')), + re_path(r'^', include('welco.sources.counter.urls')), + path('ajax/qualification', welco.views.qualification, name='qualif-zone'), + re_path( r'^ajax/remove-association/(?P\w+)$', welco.views.remove_association, name='ajax-remove-association', ), - url(r'^ajax/create-formdata/(?P\w+)$', welco.views.create_formdata, name='ajax-create-formdata'), - url(r'^ajax/kb$', welco.kb.views.zone, name='kb-zone'), - url(r'^kb/$', welco.kb.views.page_list, name='kb-home'), - url(r'^kb/add/$', welco.kb.views.page_add, name='kb-page-add'), - url(r'^kb/search/$', welco.kb.views.page_search, name='kb-page-search'), - url(r'^kb/search/json/$', welco.kb.views.page_search_json, name='kb-page-search-json'), - url(r'^kb/(?P[\w-]+)/$', welco.kb.views.page_detail, name='kb-page-view'), - url(r'^ajax/kb/(?P[\w-]+)/$', welco.kb.views.page_detail_fragment, name='kb-page-fragment'), - url(r'^kb/(?P[\w-]+)/edit$', welco.kb.views.page_edit, name='kb-page-edit'), - url(r'^kb/(?P[\w-]+)/delete$', welco.kb.views.page_delete, name='kb-page-delete'), - url(r'^ajax/contacts$', welco.contacts.views.zone, name='contacts-zone'), - url(r'^contacts/search/json/$', welco.contacts.views.search_json, name='contacts-search-json'), - url( + re_path(r'^ajax/create-formdata/(?P\w+)$', welco.views.create_formdata, name='ajax-create-formdata'), + path('ajax/kb', welco.kb.views.zone, name='kb-zone'), + path('kb/', welco.kb.views.page_list, name='kb-home'), + path('kb/add/', welco.kb.views.page_add, name='kb-page-add'), + path('kb/search/', welco.kb.views.page_search, name='kb-page-search'), + path('kb/search/json/', welco.kb.views.page_search_json, name='kb-page-search-json'), + re_path(r'^kb/(?P[\w-]+)/$', welco.kb.views.page_detail, name='kb-page-view'), + re_path(r'^ajax/kb/(?P[\w-]+)/$', welco.kb.views.page_detail_fragment, name='kb-page-fragment'), + re_path(r'^kb/(?P[\w-]+)/edit$', welco.kb.views.page_edit, name='kb-page-edit'), + re_path(r'^kb/(?P[\w-]+)/delete$', welco.kb.views.page_delete, name='kb-page-delete'), + path('ajax/contacts', welco.contacts.views.zone, name='contacts-zone'), + path('contacts/search/json/', welco.contacts.views.search_json, name='contacts-search-json'), + re_path( r'^ajax/contacts/(?P[\w-]+)/$', welco.contacts.views.contact_detail_fragment, name='contact-page-fragment', ), - url(r'^contacts/add/$', welco.contacts.views.contact_add, name='contacts-add'), - url( + path('contacts/add/', welco.contacts.views.contact_add, name='contacts-add'), + re_path( r'^ajax/summary/(?P\w+)/(?P\w+)/$', welco.views.wcs_summary, name='wcs-summary', ), - url(r'^admin/', admin.site.urls), - url(r'^logout/$', welco.views.logout, name='auth_logout'), - url(r'^login/$', welco.views.login, name='auth_login'), - url(r'^menu.json$', welco.views.menu_json, name='menu_json'), - url(r'^ckeditor/upload/', kb_manager_required(ckeditor_views.upload), name='ckeditor_upload'), - url( + re_path(r'^admin/', admin.site.urls), + path('logout/', welco.views.logout, name='auth_logout'), + path('login/', welco.views.login, name='auth_login'), + re_path(r'^menu.json$', welco.views.menu_json, name='menu_json'), + re_path(r'^ckeditor/upload/', kb_manager_required(ckeditor_views.upload), name='ckeditor_upload'), + re_path( r'^ckeditor/browse/', never_cache(kb_manager_required(ckeditor_views.browse)), name='ckeditor_browse' ), ] if 'mellon' in settings.INSTALLED_APPS: - urlpatterns.append(url(r'^accounts/mellon/', include('mellon.urls'))) + urlpatterns.append(re_path(r'^accounts/mellon/', include('mellon.urls'))) # static and media files urlpatterns += staticfiles_urlpatterns()