diff --git a/flash_update/templatetags/tags.py b/flash_update/templatetags/tags.py new file mode 100644 index 0000000000..b109bef700 --- /dev/null +++ b/flash_update/templatetags/tags.py @@ -0,0 +1,17 @@ +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 + if StorageClass == FileSystemStorage: + if settings.DEBUG: + return f"http://serve:8000{path}" # Don't use this in production + return f"https://{settings.BASE_URL}{path}" + return path diff --git a/flash_update/utils.py b/flash_update/utils.py index 3344705dc3..07468b7eaa 100644 --- a/flash_update/utils.py +++ b/flash_update/utils.py @@ -59,5 +59,4 @@ def get_email_context(instance): "actions_taken": actions_taken, "resources": resources, } - email_context = {key: value for key, value in email_context.items() if value is not None} return email_context diff --git a/main/settings.py b/main/settings.py index 1c7d586901..527d3d1780 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 3e1884d2ce..858ea1ec7d 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 %} +