From f18f35f38ff077e7d52980e69944076248021e56 Mon Sep 17 00:00:00 2001
From: Julian Keck <julian.keck9@kit.edu>
Date: Thu, 23 Jan 2025 14:21:08 +0100
Subject: [PATCH] UPD: print JSON-Object for patch-request in email

---
 api/patch_request.py                | 8 ++++++--
 templates/patch_request_template.j2 | 6 ++++++
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/api/patch_request.py b/api/patch_request.py
index bce5d0b..c8241f7 100644
--- a/api/patch_request.py
+++ b/api/patch_request.py
@@ -1,4 +1,5 @@
 import html
+import json
 import pathlib
 from typing import Optional
 
@@ -342,7 +343,7 @@ def send_informal_petch_request(message: str, mgr: Mgr, receiver=settings.patch_
         raise e
 
 
-def send_patch_request(actions, mgr: Mgr, receiver=settings.patch_request_email_receivers,
+def send_patch_request(actions: list[PatchRequestAction], mgr: Mgr, receiver=settings.patch_request_email_receivers,
                        reply_to: Optional[str] = None) -> bool:
     try:
         host_mode = db.host_omdl.OP_ENV_MODE.upper()
@@ -350,10 +351,13 @@ def send_patch_request(actions, mgr: Mgr, receiver=settings.patch_request_email_
         path = pathlib.Path(__file__).parent.parent.resolve()
         TEMPLATE = 'templates/patch_request_template.j2'
 
+        raw_action_json = json.dumps(actions)
+
         body = render_jinja_template(path, TEMPLATE,
                                      actions=actions,
                                      mgr=mgr,
-                                     host_mode=host_mode
+                                     host_mode=host_mode,
+                                     raw_action_json=raw_action_json,
                                      )
 
         building_numbers = ",".join(set([action.building.number for action in actions]))
diff --git a/templates/patch_request_template.j2 b/templates/patch_request_template.j2
index 7ecb09e..323c6d2 100644
--- a/templates/patch_request_template.j2
+++ b/templates/patch_request_template.j2
@@ -90,4 +90,10 @@
 {% endfor %}
 
 <p>Have a nice day!</p>
+<br><br>
+Raw request
+<pre>
+    {{ raw_action_json | default('[]') }}
+</pre>
+
 </body>
-- 
GitLab