From f41cbda02ba4dc0dc67b25a949fcd28e4682ee44 Mon Sep 17 00:00:00 2001 From: Axxiar Date: Mon, 14 Apr 2025 18:14:44 +0200 Subject: [PATCH 1/4] added missing implem groups when empty on html report --- backend/core/templates/core/audit_report.html | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/backend/core/templates/core/audit_report.html b/backend/core/templates/core/audit_report.html index 5f8109d346..c985b35f40 100644 --- a/backend/core/templates/core/audit_report.html +++ b/backend/core/templates/core/audit_report.html @@ -42,9 +42,15 @@

{{ compliance_assessment.name }}: {{ compliance_assessment.

{% trans "Selected implementation groups" %}

    + {% if not compliance_assessment.get_selected_implementation_groups and compliance_assessment.framework.implementation_groups_definition %} + {% for group in compliance_assessment.framework.implementation_groups_definition %} +
  • {{ group.name }}
  • + {% endfor %} + {% else %} {% for group in compliance_assessment.get_selected_implementation_groups %}
  • {{ group }}
  • {% endfor %} + {% endif %}
From 418daaccaa54ac0a80b60ecb10e2463acca25056 Mon Sep 17 00:00:00 2001 From: Axxiar Date: Mon, 14 Apr 2025 22:46:42 +0200 Subject: [PATCH 2/4] added missing implem groups when empty on word report --- backend/core/generators.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/backend/core/generators.py b/backend/core/generators.py index 28742dbc7e..e96af76a5a 100644 --- a/backend/core/generators.py +++ b/backend/core/generators.py @@ -567,6 +567,10 @@ def recursive_score_calculation(node_data): chart_spider = InlineImage(doc, spider_chart_buffer, width=Cm(15)) ac_chart = InlineImage(doc, hbar_buffer, width=Cm(15)) IGs = ", ".join([str(x) for x in audit.get_selected_implementation_groups()]) + if IGs == "" and audit.framework.implementation_groups_definition: + IGs = ", ".join( + [x.get("name") for x in audit.framework.implementation_groups_definition] + ) context = { "audit": audit, "date": now().strftime("%d/%m/%Y"), From d5e29df10d26657523a82b82a2ccd84741ddcea5 Mon Sep 17 00:00:00 2001 From: Axxiar Date: Tue, 15 Apr 2025 12:42:55 +0200 Subject: [PATCH 3/4] refactor get_selected_implementation_groups --- backend/core/models.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/backend/core/models.py b/backend/core/models.py index bd26e733e1..295b81d9ca 100644 --- a/backend/core/models.py +++ b/backend/core/models.py @@ -3212,15 +3212,18 @@ def get_global_score(self): def get_selected_implementation_groups(self): framework = self.framework - if ( - not framework.implementation_groups_definition - or not self.selected_implementation_groups - ): + igs_definition = framework.implementation_groups_definition + selected_ig = self.selected_implementation_groups + + if not igs_definition and not selected_ig: return [] + + if not selected_ig: # no selected_ig but some ig_definition -> means nothing is selected so we want every ig + return [group.get("name") for group in igs_definition] return [ group.get("name") - for group in framework.implementation_groups_definition - if group.get("ref_id") in self.selected_implementation_groups + for group in igs_definition + if group.get("ref_id") in selected_ig ] def get_requirement_assessments(self, include_non_assessable: bool): From 4834329a6e2d88df59720b5e844203f40cb028ba Mon Sep 17 00:00:00 2001 From: Axxiar Date: Tue, 15 Apr 2025 14:40:26 +0200 Subject: [PATCH 4/4] clean previous change --- backend/core/generators.py | 4 ---- backend/core/templates/core/audit_report.html | 6 ------ 2 files changed, 10 deletions(-) diff --git a/backend/core/generators.py b/backend/core/generators.py index e96af76a5a..28742dbc7e 100644 --- a/backend/core/generators.py +++ b/backend/core/generators.py @@ -567,10 +567,6 @@ def recursive_score_calculation(node_data): chart_spider = InlineImage(doc, spider_chart_buffer, width=Cm(15)) ac_chart = InlineImage(doc, hbar_buffer, width=Cm(15)) IGs = ", ".join([str(x) for x in audit.get_selected_implementation_groups()]) - if IGs == "" and audit.framework.implementation_groups_definition: - IGs = ", ".join( - [x.get("name") for x in audit.framework.implementation_groups_definition] - ) context = { "audit": audit, "date": now().strftime("%d/%m/%Y"), diff --git a/backend/core/templates/core/audit_report.html b/backend/core/templates/core/audit_report.html index c985b35f40..5f8109d346 100644 --- a/backend/core/templates/core/audit_report.html +++ b/backend/core/templates/core/audit_report.html @@ -42,15 +42,9 @@

{{ compliance_assessment.name }}: {{ compliance_assessment.

{% trans "Selected implementation groups" %}

    - {% if not compliance_assessment.get_selected_implementation_groups and compliance_assessment.framework.implementation_groups_definition %} - {% for group in compliance_assessment.framework.implementation_groups_definition %} -
  • {{ group.name }}
  • - {% endfor %} - {% else %} {% for group in compliance_assessment.get_selected_implementation_groups %}
  • {{ group }}
  • {% endfor %} - {% endif %}