mirror of
https://github.com/inventree/InvenTree.git
synced 2025-08-08 04:40:57 +00:00
Frontend server settings (#5765)
* Update ApiToken model - Add metadata - Remove unique_together requirement - Add last_seen field * Update admin page for token * Store metadata against token on creation * Track last-seen date * Allow match against existing valid token - If token is expired or revoked, create a new one - Prevents duplication of tokens * Update unit tests * Fix default server * Improve functionality for extracting frontend settings * Update default server list * Use f-strings * Revert logger name * Remove mark_safe warning
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
"""Template tag to render SPA imports."""
|
||||
|
||||
import json
|
||||
from logging import getLogger
|
||||
from pathlib import Path
|
||||
@@ -10,11 +11,7 @@ from django.utils.safestring import mark_safe
|
||||
logger = getLogger("InvenTree")
|
||||
register = template.Library()
|
||||
|
||||
PUI_DEFAULTS = {
|
||||
'url_base': settings.PUI_URL_BASE,
|
||||
}
|
||||
PUI_DEFAULTS.update(getattr(settings, 'PUI_SETTINGS', {}))
|
||||
PUI_SETTINGS = json.dumps(PUI_DEFAULTS)
|
||||
FRONTEND_SETTINGS = json.dumps(settings.FRONTEND_SETTINGS)
|
||||
|
||||
|
||||
@register.simple_tag
|
||||
@@ -30,11 +27,11 @@ def spa_bundle():
|
||||
index = manifest_data.get("index.html")
|
||||
css_index = manifest_data.get("index.css")
|
||||
|
||||
dynmanic_files = index.get("dynamicImports", [])
|
||||
dynamic_files = index.get("dynamicImports", [])
|
||||
imports_files = "".join(
|
||||
[
|
||||
f'<script type="module" src="{settings.STATIC_URL}web/{manifest_data[file]["file"]}"></script>'
|
||||
for file in dynmanic_files
|
||||
for file in dynamic_files
|
||||
]
|
||||
)
|
||||
|
||||
@@ -47,4 +44,4 @@ def spa_bundle():
|
||||
@register.simple_tag
|
||||
def spa_settings():
|
||||
"""Render settings for spa."""
|
||||
return mark_safe(f"""<script>window.INVENTREE_SETTINGS={PUI_SETTINGS}</script>""")
|
||||
return mark_safe(f"""<script>window.INVENTREE_SETTINGS={FRONTEND_SETTINGS}</script>""")
|
||||
|
@@ -20,12 +20,12 @@ spa_view = ensure_csrf_cookie(TemplateView.as_view(template_name="web/index.html
|
||||
|
||||
|
||||
urlpatterns = [
|
||||
path(f'{settings.PUI_URL_BASE}/', include([
|
||||
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.PUI_URL_BASE, spa_view, name='platform'),
|
||||
path(settings.FRONTEND_URL_BASE, spa_view, name='platform'),
|
||||
path("assets/<path:path>", RedirectAssetView.as_view()),
|
||||
]
|
||||
|
Reference in New Issue
Block a user