From cdbcfbdd804238ff20fd1a54a15a39ecd3349eeb Mon Sep 17 00:00:00 2001
From: Janis Streib <janis.streib@kit.edu>
Date: Fri, 17 Jan 2025 18:15:05 +0100
Subject: [PATCH] UPD: better mail template for patchrequest

---
 templates/patch_request_template.j2 | 94 +++++++++++++++++++++--------
 1 file changed, 69 insertions(+), 25 deletions(-)

diff --git a/templates/patch_request_template.j2 b/templates/patch_request_template.j2
index f0d6297..e54d492 100644
--- a/templates/patch_request_template.j2
+++ b/templates/patch_request_template.j2
@@ -1,48 +1,92 @@
 <body>
 <h1>Patch Request</h1>
 {% if host_mode != 'PROD' %}
-    <h2 style="color: red">This patch request was sent from a development or testing instance of NETVS and is probably just a test!</h2>
+    <h2 style="color: red">This patch request was sent from a development or testing instance of NETVS and is probably
+        just a test!</h2>
 {% endif %}
 <p>{{ mgr.first_name }} {{ mgr.last_name }} ({{ mgr.email|urlize }}) would like you to fulfill
     the following patch request:</p>
 
 {% for action in actions %}
-    <code><h3>Action {{ loop.index }}:</h3>
-        <b>Building:</b> {{ action['building']['site_fq_name'] }} {{ action['building']['number'] }}
-        ({{ action['building']['name'] }})<br>
-        <b>Room:</b> {{ action['room']['number'] }} ({{ action['room']['name'] }})<br>
-        <b>Module:</b> {{ action['module']['label'] }} ({{ action['module']['type'] }})<br>
-        <b>Action:</b> {{ action['action'].value }}<br>
+    <h3>Action ({{ action['action'].value }}) {{ loop.index }}:</h3>
+    <table style="width: 100%; border: 1px solid black; border-collapse: collapse;">
+        <tr>
+            <th style="border: 1px solid black; border-collapse: collapse;">Action</th>
+            <td style="border: 1px solid black; border-collapse: collapse; {%if action['action'].value != 'patch'%} color: #ff0000;{%endif%}">{{ action['action'].value }}</td>
+        </tr>
+        <tr>
+            <th style="border: 1px solid black; border-collapse: collapse;">Comment</th>
+            <td style="border: 1px solid black; border-collapse: collapse; color: #ff0000">{{ action['comment'] }}</td>
+        </tr>
+        <tr>
+            <th style="border: 1px solid black; border-collapse: collapse;">Building</th>
+            <td style="border: 1px solid black; border-collapse: collapse;">{{ action['building']['site_fq_name'] }} {{ action['building']['number'] }}
+                ({{ action['building']['name'] }})
+            </td>
+        </tr>
+        <tr>
+            <th style="border: 1px solid black; border-collapse: collapse;">Room</th>
+            <td style="border: 1px solid black; border-collapse: collapse;">{{ action['room']['number'] }} ({{ action['room']['name'] }})</td>
+        </tr>
+        <tr>
+            <th style="border: 1px solid black; border-collapse: collapse;">Module</th>
+            <td style="border: 1px solid black; border-collapse: collapse;">{{ action['module']['label'] }} ({{ action['module']['type'] }})</td>
+        </tr>
         {% if action['action'].value != 'change_insert' %}
-        <b>Port:</b> {{ action['p_port']['name'] }}<br>
+            <tr>
+                <th style="border: 1px solid black; border-collapse: collapse;">Port</th>
+                <td style="border: 1px solid black; border-collapse: collapse;">{{ action['p_port']['name'] }}</td>
+            </tr>
         {% endif %}
         {% if action['bcd'] is defined and action['bcd']['name'] is defined %}
-        <b>Broadcast domain:</b> {{ action['bcd']['name'] }} ({% if action['bcd_tagged'] %}add tagged{%else%}untagged{%endif%})<br>
-        <ul>
-        {% for v in action['vlan_ids'] %}
-            <li>{{ v }}</li>
-        {% endfor %}
-        </ul>
+            <tr>
+                <th style="border: 1px solid black; border-collapse: collapse;">Broadcast Domain</th>
+                <td style="border: 1px solid black; border-collapse: collapse;">{{ action['bcd']['name'] }} ({% if action['bcd_tagged'] %}add tagged{% else %}untagged{% endif %})
+                </td>
+            </tr>
+            <ul>
+                {% for v in action['vlan_ids'] %}
+                    <li>{{ v }}</li>
+                {% endfor %}
+            </ul>
         {% endif %}
         {% if action['new_insert_type'] %}
-        <b>New insert:</b> {{ action['new_insert_type'] }}<br>
+            <tr>
+                <th style="border: 1px solid black; border-collapse: collapse;">New Insert</th>
+                <td style="border: 1px solid black; border-collapse: collapse;">{{ action['new_insert_type'] }}</td>
+            </tr>
         {% endif %}
         {% if action['new_insert_assignment'] is defined and (action['new_insert_assignment'] | length > 0) %}
-        <b>BCD-assignment:</b> the following BCDs should be assigned to the new insert. Port names are only estimated, you might need to adjust them:<br>
-        <ul>
-            {% for assignment in action['new_insert_assignment'] %}
-                <li>{{ assignment['port_name'] }}: {{ assignment['bcd_name'] }} ({% if not assignment['bcd_tagged'] %}un{% endif %}tagged)</li>
-            {% endfor %}
-        </ul>
+            <tr>
+                <th style="border: 1px solid black; border-collapse: collapse;">BCD Assignment</th>
+                <td style="border: 1px solid black; border-collapse: collapse;">The following BCDs should be assigned to the new insert. Port names are only estimated, you might
+                    need to adjust them:
+                    <ul>
+                        {% for assignment in action['new_insert_assignment'] %}
+                            <li>{{ assignment['port_name'] }}: {{ assignment['bcd_name'] }} (
+                                {% if not assignment['bcd_tagged'] %}un{% endif %}tagged)
+                            </li>
+                        {% endfor %}
+                    </ul>
+                </td>
+            </tr>
         {% endif %}
-        <b>Comment:</b> {{ action['comment'] }}<br>
         {% if (action['path_link'] | default(none)) is not none %}
-            <b>Link to path:</b> <a href="{{ action['path_link'] }}">{{ action['path_link'] }}</a><br>
+            <tr>
+                <th style="border: 1px solid black; border-collapse: collapse;">Link to path</th>
+                <td style="border: 1px solid black; border-collapse: collapse;"><a href="{{ action['path_link'] }}">{{ action['path_link'] }}</a></td>
+            </tr>
         {% endif %}
         {% if (action['ports_summary'] | default(none)) is not none %}
-            <b>Current path:</b> <span>{{ action['ports_summary'] }}</span>
+            <tr>
+                <th style="border: 1px solid black; border-collapse: collapse;">Current path</th>
+                <td style="border: 1px solid black; border-collapse: collapse;"><span>{{ action['ports_summary'] }}</span></td>
+            </tr>
         {% endif %}
-    </code><br>
+    </table>
+    {% if not loop.last %}
+        <hl/>
+    {% endif %}
 {% endfor %}
 
 <p>Have a nice day!</p>
-- 
GitLab