Add custom report template tags

This commit is contained in:
Oliver Walters 2021-02-04 13:41:47 +11:00
parent 801b945438
commit 6230fb3614

View File

@ -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}"