[PUI] URL fixes (#5989)

* added helper to render an instance for an url

* removed unneeded declaration

* restructed PUI urls to improve behaviour:
- removes dead routes
- adds percausion to make sure asset-matching path is always the same
- makes sure subpaths of the PUI path also match to PUI (fixing a current bug with fully reload PUI)

* clean up diff
This commit is contained in:
Matthias Mair 2023-11-27 01:51:53 +01:00 committed by GitHub
parent 87df9245eb
commit fac66b289b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 12 deletions

View File

@ -217,9 +217,6 @@ classic_frontendpatterns = [
re_path(r'^accounts/', include('allauth.urls')), # included urlpatterns
]
new_frontendpatterns = platform_urls
urlpatterns = []
if settings.INVENTREE_ADMIN_ENABLED:
@ -236,7 +233,7 @@ frontendpatterns = []
if settings.ENABLE_CLASSIC_FRONTEND:
frontendpatterns += classic_frontendpatterns
if settings.ENABLE_PLATFORM_FRONTEND:
frontendpatterns += new_frontendpatterns
frontendpatterns += platform_urls
urlpatterns += frontendpatterns

View File

@ -17,15 +17,15 @@ class RedirectAssetView(TemplateView):
spa_view = ensure_csrf_cookie(TemplateView.as_view(template_name="web/index.html"))
assets_path = path("assets/<path:path>", RedirectAssetView.as_view())
urlpatterns = [
path(f'{settings.FRONTEND_URL_BASE}/', include([
path("assets/<path:path>", RedirectAssetView.as_view()),
re_path(r"^(?P<path>.*)/$", spa_view),
path("set-password?uid=<uid>&token=<token>", spa_view, name="password_reset_confirm"),
path("", spa_view),]
)),
path(settings.FRONTEND_URL_BASE, spa_view, name='platform'),
path("assets/<path:path>", RedirectAssetView.as_view()),
path(f"{settings.FRONTEND_URL_BASE}/", include([
assets_path,
path("set-password?uid=<uid>&token=<token>", spa_view, name="password_reset_confirm",),
re_path(".*", spa_view),
])),
assets_path,
path(settings.FRONTEND_URL_BASE, spa_view, name="platform"),
]