From 636bae17378a913f978a7ce884ac88b60c48fe20 Mon Sep 17 00:00:00 2001 From: Sushil Tiwari Date: Fri, 22 Nov 2024 14:29:44 +0545 Subject: [PATCH 1/2] Remove None key value in pdf export Remove None fields from email and pdf --- flash_update/utils.py | 1 + 1 file changed, 1 insertion(+) diff --git a/flash_update/utils.py b/flash_update/utils.py index 07468b7ea..3344705dc 100644 --- a/flash_update/utils.py +++ b/flash_update/utils.py @@ -59,4 +59,5 @@ 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 From 424f3ad008186f750999582964557852b3208045 Mon Sep 17 00:00:00 2001 From: Sushil Tiwari Date: Wed, 27 Nov 2024 16:08:35 +0545 Subject: [PATCH 2/2] Change flash update html export --- flash_update/templatetags/tags.py | 18 +++++ flash_update/utils.py | 1 - main/settings.py | 1 + .../email/flash_update/flash_pdf.html | 81 +++++++++++++------ 4 files changed, 74 insertions(+), 27 deletions(-) create mode 100644 flash_update/templatetags/tags.py 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/flash_update/utils.py b/flash_update/utils.py index 3344705dc..07468b7ea 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 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 %} +