2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-04-28 11:36:44 +00:00
Matthias Mair fac66b289b
[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
2023-11-27 11:51:53 +11:00

32 lines
1004 B
Python

"""URLs for web app."""
from django.conf import settings
from django.shortcuts import redirect
from django.urls import include, path, re_path
from django.views.decorators.csrf import ensure_csrf_cookie
from django.views.generic import TemplateView
class RedirectAssetView(TemplateView):
"""View to redirect to static asset."""
def get(self, request, *args, **kwargs):
"""Redirect to static asset."""
return redirect(
f"{settings.STATIC_URL}web/assets/{kwargs['path']}", permanent=True
)
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([
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"),
]