From 13351931a3d62a2537f05aff733cb4d8c6522384 Mon Sep 17 00:00:00 2001 From: Mohamed-Hacene Date: Fri, 17 May 2024 13:55:37 +0200 Subject: [PATCH] fix: risk assessment pdf export --- backend/core/templates/core/base_pdf.html | 9 ++++++ backend/core/templates/snippets/ra_data.html | 31 +++++++++++++------ .../templates/snippets/ri_list_nested.html | 20 +++++++++--- .../core/templates/snippets/risk_matrix.html | 16 +++++----- 4 files changed, 53 insertions(+), 23 deletions(-) diff --git a/backend/core/templates/core/base_pdf.html b/backend/core/templates/core/base_pdf.html index 60517e7fb..9ae07a2b2 100644 --- a/backend/core/templates/core/base_pdf.html +++ b/backend/core/templates/core/base_pdf.html @@ -23,6 +23,9 @@ .flex { display: flex; } +.flex-row { + flex-direction: row; +} .table { display: table; } @@ -234,6 +237,9 @@ .ml-3 { margin-left: 0.75rem; } +.ml-13 { + margin-left: 3.25rem; +} .p-1 { padding: 0.25rem; } @@ -267,6 +273,9 @@ .mt-10 { margin-top: 2.5rem; } +.mt-45{ + margin-top: 11.25rem; +} .justify-center { justify-content: center; diff --git a/backend/core/templates/snippets/ra_data.html b/backend/core/templates/snippets/ra_data.html index 4c26c57b3..3c5bb5c49 100644 --- a/backend/core/templates/snippets/ra_data.html +++ b/backend/core/templates/snippets/ra_data.html @@ -3,13 +3,18 @@
-
-
+
+
{% trans "Risk assessment" %}
-
{{ risk_assessment }}
+
{{ risk_assessment }}

    +
  • {% trans "Risk matrix:" %} +
      +
    • {{ risk_assessment.risk_matrix }}
    • +
    +
  • {% trans "Authors:" %}
      {% for author in risk_assessment.authors.all %} @@ -17,18 +22,24 @@ {% endfor %}
  • -
  • {% trans "Status:" %} {% if risk_assessment.is_draft %} - {% trans "Draft" %} {% else %} {% trans "Ready" %} {% endif %} +
  • {% trans "Reviewers:" %} +
      + {% for author in risk_assessment.reviewers.all %} +
    • {{ author }}
    • + {% endfor %} +
    +
  • +
  • {% trans "Status:" %} + {% if risk_assessment.status %} {{risk_assessment.status}} {% else %} -- {% endif %}
  • +
  • {% trans "ETA:" %} {{ risk_assessment.eta|date }}
  • +
  • {% trans "Due date:" %} {{ risk_assessment.due_date|date }}
  • {% trans "Created at:" %} {{ risk_assessment.created_at|date }}
  • {% trans "Updated at:" %} {{ risk_assessment.updated_at|date }}
-
{% trans "Risk matrix:" %}

{{ risk_assessment.risk_matrix }}

-
-
{% trans "Description" %}:
{% if risk_assessment.description %}{{ risk_assessment.description|linebreaksbr }}{% endif %}
@@ -37,12 +48,12 @@
-
{% trans "Risk scenarios" %} ({{ context|length }})
+

{% trans "Associated Risk scenarios" %} ({{ context|length }}):

{% include 'snippets/ri_list_nested.html' %}
-
{% trans "Risk matrix view" %}
+
{% trans "Risk matrix view" %}

{% trans "Current" %}

diff --git a/backend/core/templates/snippets/ri_list_nested.html b/backend/core/templates/snippets/ri_list_nested.html index f830aa110..6a2e7254b 100644 --- a/backend/core/templates/snippets/ri_list_nested.html +++ b/backend/core/templates/snippets/ri_list_nested.html @@ -1,7 +1,13 @@ {% load i18n %} {% load static tailwind_tags %} - + + +
{% for scenario in scenarios %} - + @@ -45,9 +51,13 @@
{% trans "ID" %} @@ -30,7 +36,7 @@
{{ scenario.rid }} -

- {% if scenario.threat %}{{ scenario.threat }}{% else %}--{% endif %} -

+ {% for threat in scenario.threats.all %} +

+ {{ threat }} +

+ {% empty %} + -- + {% endfor %}

{{ scenario.existing_controls|linebreaksbr }}

diff --git a/backend/core/templates/snippets/risk_matrix.html b/backend/core/templates/snippets/risk_matrix.html index 9b4614c90..e67f2b070 100644 --- a/backend/core/templates/snippets/risk_matrix.html +++ b/backend/core/templates/snippets/risk_matrix.html @@ -41,18 +41,18 @@ {% else %}
-
-
{% trans "Impact" %}