update urls too

This commit is contained in:
Matthias 2021-11-15 00:10:05 +01:00
parent 5b04f812a9
commit 84a675ae39
No known key found for this signature in database
GPG Key ID: F50EF5741D33E076

View File

@ -8,7 +8,7 @@ from typing import OrderedDict
from django.apps import AppConfig, apps from django.apps import AppConfig, apps
from django.conf import settings from django.conf import settings
from django.db.utils import OperationalError, ProgrammingError from django.db.utils import OperationalError, ProgrammingError
from django.conf.urls import url from django.conf.urls import url, include
from django.contrib import admin from django.contrib import admin
try: try:
@ -217,13 +217,15 @@ class PluginAppConfig(AppConfig):
self._update_urls() self._update_urls()
def _update_urls(self): def _update_urls(self):
from InvenTree.urls import urlpatterns as root_urlpatterns from InvenTree.urls import urlpatterns, get_integration_urls
for index, a in enumerate(root_urlpatterns): for index, a in enumerate(urlpatterns):
if hasattr(a, 'app_name') and a.app_name == 'admin': if hasattr(a, 'app_name'):
root_urlpatterns[index] = url(r'^admin/', admin.site.urls, name='inventree-admin') if a.app_name == 'admin':
print('exchanged') urlpatterns[index] = url(r'^admin/', admin.site.urls, name='inventree-admin')
break elif a.app_name == 'plugin':
integ_urls = get_integration_urls()
urlpatterns[index] = url(f'^{settings.PLUGIN_URL}/', include((integ_urls, 'plugin')))
print('done') print('done')
def _reload_apps(self, populate: bool = False): def _reload_apps(self, populate: bool = False):