From 4e9f3959b4c269683302f51eae594ac2c6e5dd08 Mon Sep 17 00:00:00 2001
From: Jay Varner
Date: Mon, 25 Nov 2024 11:11:40 -0500
Subject: [PATCH] Split up warnings in email
---
readux_ingest_ecds/mail.py | 6 +++++-
readux_ingest_ecds/tasks.py | 2 +-
readux_ingest_ecds/templates/ingest_ecds_success_email.html | 6 +++++-
readux_ingest_ecds/templates/ingest_ecds_success_email.txt | 2 +-
4 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/readux_ingest_ecds/mail.py b/readux_ingest_ecds/mail.py
index 8c7cf48..b939c35 100644
--- a/readux_ingest_ecds/mail.py
+++ b/readux_ingest_ecds/mail.py
@@ -44,9 +44,13 @@ def send_email_on_success(creator=None, manifest=None, warnings=None):
)
context["manifest_pid"] = manifest.pid
context["volume_url"] = manifest.get_volume_url()
- context["warnings"] = (
+ ingest_warnings = (
warnings if warnings is not None and len(warnings) > 10 else None
)
+ context["warnings"] = (
+ ingest_warnings.split("$$$$") if ingest_warnings is not None else None
+ )
+
html_email = get_template("ingest_ecds_success_email.html").render(context)
text_email = get_template("ingest_ecds_success_email.txt").render(context)
if creator is not None:
diff --git a/readux_ingest_ecds/tasks.py b/readux_ingest_ecds/tasks.py
index 74bfbef..f56fd40 100644
--- a/readux_ingest_ecds/tasks.py
+++ b/readux_ingest_ecds/tasks.py
@@ -116,7 +116,7 @@ def add_ocr_task_local(ingest_id, manifest_pid, *args, **kwargs):
local_ingest = Local.objects.get(pk=ingest_id)
manifest = Manifest.objects.get(pk=local_ingest.manifest.pk)
warnings = add_ocr_to_canvases(manifest)
- local_ingest.warnings = "\n".join(warnings)
+ local_ingest.warnings = "$$$$".join(warnings)
local_ingest.save()
diff --git a/readux_ingest_ecds/templates/ingest_ecds_success_email.html b/readux_ingest_ecds/templates/ingest_ecds_success_email.html
index dcd5042..4748d24 100644
--- a/readux_ingest_ecds/templates/ingest_ecds_success_email.html
+++ b/readux_ingest_ecds/templates/ingest_ecds_success_email.html
@@ -14,5 +14,9 @@ Ingest complete: {{ manifest_pid }}
{% if warnings is not None %}
Warnings
- {{warnings}}
+
+ {% for warning in warnings %}
+ - {{ warning }}
+ {% endfor %}
+
{% endif %}
\ No newline at end of file
diff --git a/readux_ingest_ecds/templates/ingest_ecds_success_email.txt b/readux_ingest_ecds/templates/ingest_ecds_success_email.txt
index fe65323..217fc5b 100644
--- a/readux_ingest_ecds/templates/ingest_ecds_success_email.txt
+++ b/readux_ingest_ecds/templates/ingest_ecds_success_email.txt
@@ -8,5 +8,5 @@ Ingest complete: {{ manifest_pid }}
- Link to volume: {{ volume_url }}
{% if warnings is not None %}
- Warnings:
-{{ warnings }}
+{{ warnings|join:"\n" }}
{% endif %}