diff --git a/InvenTree/part/templatetags/report.py b/InvenTree/part/templatetags/report.py new file mode 100644 index 0000000000..32eec76db0 --- /dev/null +++ b/InvenTree/part/templatetags/report.py @@ -0,0 +1,22 @@ +""" +Custom template tags for report generation +""" + +import os + +from django import template +from django.conf import settings + +register = template.Library() + + +@register.simple_tag() +def asset(filename): + """ + Return fully-qualified path for an upload report asset file. + """ + + path = os.path.join(settings.MEDIA_ROOT, 'report', 'assets', filename) + path = os.path.abspath(path) + + return f"file://{path}"