From 0f3b719c80708093ab333238a81f243329892970 Mon Sep 17 00:00:00 2001 From: Lukas <76838159+wolflu05@users.noreply.github.com> Date: Tue, 30 Jul 2024 12:51:57 +0200 Subject: [PATCH] Backport `plugin_static` template tag to 0.15.x (#7764) --- .../plugin/templatetags/plugin_extras.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/backend/InvenTree/plugin/templatetags/plugin_extras.py b/src/backend/InvenTree/plugin/templatetags/plugin_extras.py index 0483b1588e..334c2cfeb7 100644 --- a/src/backend/InvenTree/plugin/templatetags/plugin_extras.py +++ b/src/backend/InvenTree/plugin/templatetags/plugin_extras.py @@ -2,6 +2,7 @@ from django import template from django.conf import settings as djangosettings +from django.templatetags.static import static from django.urls import reverse from common.models import InvenTreeSetting @@ -96,3 +97,17 @@ def notification_list(context, *args, **kwargs): } for a in storage.liste ] + + +@register.simple_tag() +def plugin_static(file: str, **kwargs): + """Return the URL for a static file within a plugin. + + Arguments: + file: The path to the file within the plugin static directory + + Keyword Arguments: + plugin: The plugin slug (optional, will be inferred from the context if not provided) + + """ + return static(file)