diff --git a/flash_update/templatetags/tags.py b/flash_update/templatetags/tags.py new file mode 100644 index 000000000..b0d12416e --- /dev/null +++ b/flash_update/templatetags/tags.py @@ -0,0 +1,18 @@ +from django import template +from django.conf import settings +from django.core.files.storage import FileSystemStorage, get_storage_class + +register = template.Library() + +StorageClass = get_storage_class() + + +@register.filter(is_safe=True) +def media_full_path(path): + # TODO: Refactor http and https + # NOTE: This should point to the goadmin FullURL + if StorageClass == FileSystemStorage: + if settings.DEBUG: + return f"http://serve:8000{path}" + return f"https://{settings.BASE_URL}{path}" + return path diff --git a/main/settings.py b/main/settings.py index 1c7d58690..527d3d178 100644 --- a/main/settings.py +++ b/main/settings.py @@ -137,6 +137,7 @@ ALLOWED_HOSTS = [ "localhost", + "serve", "0.0.0.0", GO_API_FQDN, *env("DJANGO_ADDITIONAL_ALLOWED_HOSTS"), diff --git a/notifications/templates/email/flash_update/flash_pdf.html b/notifications/templates/email/flash_update/flash_pdf.html index 3e1884d2c..499bde407 100644 --- a/notifications/templates/email/flash_update/flash_pdf.html +++ b/notifications/templates/email/flash_update/flash_pdf.html @@ -1,3 +1,6 @@ +{% load static %} +{% load tags %} +