mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
fix old url() usage
This commit is contained in:
parent
de6507e918
commit
e7a0cf7342
@ -1,7 +1,7 @@
|
|||||||
from django.shortcuts import HttpResponseRedirect
|
from django.shortcuts import HttpResponseRedirect
|
||||||
from django.urls import reverse_lazy, Resolver404
|
from django.urls import reverse_lazy, Resolver404
|
||||||
from django.shortcuts import redirect
|
from django.shortcuts import redirect
|
||||||
from django.conf.urls import include, url
|
from django.urls import include, re_path
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.contrib.auth.middleware import PersistentRemoteUserMiddleware
|
from django.contrib.auth.middleware import PersistentRemoteUserMiddleware
|
||||||
|
|
||||||
@ -92,7 +92,7 @@ class AuthRequiredMiddleware(object):
|
|||||||
return response
|
return response
|
||||||
|
|
||||||
|
|
||||||
url_matcher = url('', include(frontendpatterns))
|
url_matcher = re_path('', include(frontendpatterns))
|
||||||
|
|
||||||
|
|
||||||
class Check2FAMiddleware(BaseRequire2FAMiddleware):
|
class Check2FAMiddleware(BaseRequire2FAMiddleware):
|
||||||
|
@ -7,7 +7,7 @@ from PIL import Image
|
|||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.conf.urls import url, include
|
from django.urls import include, re_path
|
||||||
from django.core.exceptions import ValidationError, FieldError
|
from django.core.exceptions import ValidationError, FieldError
|
||||||
from django.http import HttpResponse, JsonResponse
|
from django.http import HttpResponse, JsonResponse
|
||||||
|
|
||||||
@ -579,38 +579,38 @@ class PartLabelPrint(generics.RetrieveAPIView, PartLabelMixin, LabelPrintMixin):
|
|||||||
label_api_urls = [
|
label_api_urls = [
|
||||||
|
|
||||||
# Stock item labels
|
# Stock item labels
|
||||||
url(r'stock/', include([
|
re_path(r'stock/', include([
|
||||||
# Detail views
|
# Detail views
|
||||||
url(r'^(?P<pk>\d+)/', include([
|
re_path(r'^(?P<pk>\d+)/', include([
|
||||||
url(r'print/?', StockItemLabelPrint.as_view(), name='api-stockitem-label-print'),
|
re_path(r'print/?', StockItemLabelPrint.as_view(), name='api-stockitem-label-print'),
|
||||||
url(r'^.*$', StockItemLabelDetail.as_view(), name='api-stockitem-label-detail'),
|
re_path(r'^.*$', StockItemLabelDetail.as_view(), name='api-stockitem-label-detail'),
|
||||||
])),
|
])),
|
||||||
|
|
||||||
# List view
|
# List view
|
||||||
url(r'^.*$', StockItemLabelList.as_view(), name='api-stockitem-label-list'),
|
re_path(r'^.*$', StockItemLabelList.as_view(), name='api-stockitem-label-list'),
|
||||||
])),
|
])),
|
||||||
|
|
||||||
# Stock location labels
|
# Stock location labels
|
||||||
url(r'location/', include([
|
re_path(r'location/', include([
|
||||||
# Detail views
|
# Detail views
|
||||||
url(r'^(?P<pk>\d+)/', include([
|
re_path(r'^(?P<pk>\d+)/', include([
|
||||||
url(r'print/?', StockLocationLabelPrint.as_view(), name='api-stocklocation-label-print'),
|
re_path(r'print/?', StockLocationLabelPrint.as_view(), name='api-stocklocation-label-print'),
|
||||||
url(r'^.*$', StockLocationLabelDetail.as_view(), name='api-stocklocation-label-detail'),
|
re_path(r'^.*$', StockLocationLabelDetail.as_view(), name='api-stocklocation-label-detail'),
|
||||||
])),
|
])),
|
||||||
|
|
||||||
# List view
|
# List view
|
||||||
url(r'^.*$', StockLocationLabelList.as_view(), name='api-stocklocation-label-list'),
|
re_path(r'^.*$', StockLocationLabelList.as_view(), name='api-stocklocation-label-list'),
|
||||||
])),
|
])),
|
||||||
|
|
||||||
# Part labels
|
# Part labels
|
||||||
url(r'^part/', include([
|
re_path(r'^part/', include([
|
||||||
# Detail views
|
# Detail views
|
||||||
url(r'^(?P<pk>\d+)/', include([
|
re_path(r'^(?P<pk>\d+)/', include([
|
||||||
url(r'^print/', PartLabelPrint.as_view(), name='api-part-label-print'),
|
re_path(r'^print/', PartLabelPrint.as_view(), name='api-part-label-print'),
|
||||||
url(r'^.*$', PartLabelDetail.as_view(), name='api-part-label-detail'),
|
re_path(r'^.*$', PartLabelDetail.as_view(), name='api-part-label-detail'),
|
||||||
])),
|
])),
|
||||||
|
|
||||||
# List view
|
# List view
|
||||||
url(r'^.*$', PartLabelList.as_view(), name='api-part-label-list'),
|
re_path(r'^.*$', PartLabelList.as_view(), name='api-part-label-list'),
|
||||||
])),
|
])),
|
||||||
]
|
]
|
||||||
|
@ -17,7 +17,7 @@ from importlib import reload
|
|||||||
from django.apps import apps
|
from django.apps import apps
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.db.utils import OperationalError, ProgrammingError, IntegrityError
|
from django.db.utils import OperationalError, ProgrammingError, IntegrityError
|
||||||
from django.conf.urls import url, include
|
from django.urls import include, re_path
|
||||||
from django.urls import clear_url_caches
|
from django.urls import clear_url_caches
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
from django.utils.text import slugify
|
from django.utils.text import slugify
|
||||||
@ -570,12 +570,12 @@ class PluginsRegistry:
|
|||||||
for index, a in enumerate(urlpatterns):
|
for index, a in enumerate(urlpatterns):
|
||||||
if hasattr(a, 'app_name'):
|
if hasattr(a, 'app_name'):
|
||||||
if a.app_name == 'admin':
|
if a.app_name == 'admin':
|
||||||
urlpatterns[index] = url(r'^admin/', admin.site.urls, name='inventree-admin')
|
urlpatterns[index] = re_path(r'^admin/', admin.site.urls, name='inventree-admin')
|
||||||
elif a.app_name == 'plugin':
|
elif a.app_name == 'plugin':
|
||||||
urlpatterns[index] = get_plugin_urls()
|
urlpatterns[index] = get_plugin_urls()
|
||||||
|
|
||||||
# replace frontendpatterns
|
# replace frontendpatterns
|
||||||
global_pattern[0] = url('', include(urlpatterns))
|
global_pattern[0] = re_path('', include(urlpatterns))
|
||||||
clear_url_caches()
|
clear_url_caches()
|
||||||
|
|
||||||
def _reload_apps(self, force_reload: bool = False):
|
def _reload_apps(self, force_reload: bool = False):
|
||||||
|
@ -28,13 +28,13 @@ class SampleIntegrationPlugin(AppMixin, SettingsMixin, UrlsMixin, NavigationMixi
|
|||||||
|
|
||||||
def setup_urls(self):
|
def setup_urls(self):
|
||||||
he_urls = [
|
he_urls = [
|
||||||
url(r'^he/', self.view_test, name='he'),
|
re_path(r'^he/', self.view_test, name='he'),
|
||||||
url(r'^ha/', self.view_test, name='ha'),
|
re_path(r'^ha/', self.view_test, name='ha'),
|
||||||
]
|
]
|
||||||
|
|
||||||
return [
|
return [
|
||||||
url(r'^hi/', self.view_test, name='hi'),
|
re_path(r'^hi/', self.view_test, name='hi'),
|
||||||
url(r'^ho/', include(he_urls), name='ho'),
|
re_path(r'^ho/', include(he_urls), name='ho'),
|
||||||
]
|
]
|
||||||
|
|
||||||
SETTINGS = {
|
SETTINGS = {
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.conf.urls import url, include
|
from django.urls import include, re_path
|
||||||
from django.contrib.auth import get_user_model
|
from django.contrib.auth import get_user_model
|
||||||
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
@ -66,7 +66,7 @@ class UrlsMixinTest(BaseMixinDefinition, TestCase):
|
|||||||
class UrlsCls(UrlsMixin, IntegrationPluginBase):
|
class UrlsCls(UrlsMixin, IntegrationPluginBase):
|
||||||
def test():
|
def test():
|
||||||
return 'ccc'
|
return 'ccc'
|
||||||
URLS = [url('testpath', test, name='test'), ]
|
URLS = [re_path('testpath', test, name='test'), ]
|
||||||
self.mixin = UrlsCls()
|
self.mixin = UrlsCls()
|
||||||
|
|
||||||
class NoUrlsCls(UrlsMixin, IntegrationPluginBase):
|
class NoUrlsCls(UrlsMixin, IntegrationPluginBase):
|
||||||
@ -81,7 +81,7 @@ class UrlsMixinTest(BaseMixinDefinition, TestCase):
|
|||||||
self.assertEqual(self.mixin.base_url, target_url)
|
self.assertEqual(self.mixin.base_url, target_url)
|
||||||
|
|
||||||
# urlpattern
|
# urlpattern
|
||||||
target_pattern = url(f'^{plg_name}/', include((self.mixin.urls, plg_name)), name=plg_name)
|
target_pattern = re_path(f'^{plg_name}/', include((self.mixin.urls, plg_name)), name=plg_name)
|
||||||
self.assertEqual(self.mixin.urlpatterns.reverse_dict, target_pattern.reverse_dict)
|
self.assertEqual(self.mixin.urlpatterns.reverse_dict, target_pattern.reverse_dict)
|
||||||
|
|
||||||
# resolve the view
|
# resolve the view
|
||||||
|
Loading…
Reference in New Issue
Block a user