From 42c17599187ab27e85d163b5c37e33eb29ac33ba Mon Sep 17 00:00:00 2001 From: Axxiar Date: Fri, 22 Nov 2024 18:01:09 +0100 Subject: [PATCH 01/10] chore: serialize urn & parent_urn in requirement assessment --- backend/core/serializers.py | 1 + .../[id=uuid]/edit/+page.server.ts | 10 ++++------ 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/backend/core/serializers.py b/backend/core/serializers.py index 68e5f8bd5..0020da471 100644 --- a/backend/core/serializers.py +++ b/backend/core/serializers.py @@ -613,6 +613,7 @@ class RequirementAssessmentReadSerializer(BaseModelSerializer): compliance_assessment = FieldsRelatedField() folder = FieldsRelatedField() assessable = serializers.BooleanField(source="requirement.assessable") + requirement = FieldsRelatedField(["urn", "parent_urn"]) class Meta: model = RequirementAssessment diff --git a/frontend/src/routes/(app)/(third-party)/requirement-assessments/[id=uuid]/edit/+page.server.ts b/frontend/src/routes/(app)/(third-party)/requirement-assessments/[id=uuid]/edit/+page.server.ts index a3fd98236..2be95e97e 100644 --- a/frontend/src/routes/(app)/(third-party)/requirement-assessments/[id=uuid]/edit/+page.server.ts +++ b/frontend/src/routes/(app)/(third-party)/requirement-assessments/[id=uuid]/edit/+page.server.ts @@ -29,12 +29,10 @@ export const load = (async ({ fetch, params }) => { } const requirementAssessment = await fetchJson(endpoint); - const [compliance_assessment_score, requirement] = await Promise.all([ - fetchJson( - `${baseUrl}/compliance-assessments/${requirementAssessment.compliance_assessment.id}/global_score/` - ), - fetchJson(`${baseUrl}/requirement-nodes/${requirementAssessment.requirement}/`) - ]); + const requirement = requirementAssessment.requirement; + const compliance_assessment_score = await fetchJson( + `${baseUrl}/compliance-assessments/${requirementAssessment.compliance_assessment.id}/global_score/` + ); const parent = await fetchJson( `${baseUrl}/requirement-nodes/?urn=${requirement.parent_urn}` From 7211fe8fdcd4b8e66ba7fc6c708f4c50762e3464 Mon Sep 17 00:00:00 2001 From: Mohamed-Hacene Date: Wed, 27 Nov 2024 16:09:42 +0100 Subject: [PATCH 02/10] feat: serialize requirement node inside requirement assessment --- backend/core/models.py | 34 +++++++++++++++++++ backend/core/serializers.py | 2 +- .../[id=uuid]/edit/+page.server.ts | 6 ++-- .../[id=uuid]/edit/+page.svelte | 8 ++--- 4 files changed, 42 insertions(+), 8 deletions(-) diff --git a/backend/core/models.py b/backend/core/models.py index abc4048ae..ef37115a1 100644 --- a/backend/core/models.py +++ b/backend/core/models.py @@ -1048,6 +1048,40 @@ class RequirementNode(ReferentialObjectMixin, I18nObjectMixin): null=True, blank=True, verbose_name=_("Typical evidence") ) question = models.JSONField(blank=True, null=True, verbose_name=_("Question")) + + @property + def associated_reference_controls(self): + _reference_controls = self.reference_controls.all() + reference_controls = [] + for control in _reference_controls: + reference_controls.append( + {"str": control.display_long, "urn": control.urn, "id": control.id} + ) + return reference_controls + + @property + def associated_threats(self): + _threats = self.threats.all() + threats = [] + for control in _threats: + threats.append( + {"str": control.display_long, "urn": control.urn, "id": control.id} + ) + return threats + + @property + def parent_requirement(self): + parent_requirement = RequirementNode.objects.filter(urn=self.parent_urn).first() + if not parent_requirement: + return None + return { + "str": parent_requirement.display_long, + "urn": parent_requirement.urn, + "id": parent_requirement.id, + "ref_id": parent_requirement.ref_id, + "name": parent_requirement.name, + "description": parent_requirement.description + } class Meta: verbose_name = _("RequirementNode") diff --git a/backend/core/serializers.py b/backend/core/serializers.py index 0020da471..da0c3e1e0 100644 --- a/backend/core/serializers.py +++ b/backend/core/serializers.py @@ -613,7 +613,7 @@ class RequirementAssessmentReadSerializer(BaseModelSerializer): compliance_assessment = FieldsRelatedField() folder = FieldsRelatedField() assessable = serializers.BooleanField(source="requirement.assessable") - requirement = FieldsRelatedField(["urn", "parent_urn"]) + requirement = FieldsRelatedField(["urn", "annotation", "name", "description", "typical_evidence", "ref_id", "associated_reference_controls", "associated_threats", "parent_requirement"]) class Meta: model = RequirementAssessment diff --git a/frontend/src/routes/(app)/(third-party)/requirement-assessments/[id=uuid]/edit/+page.server.ts b/frontend/src/routes/(app)/(third-party)/requirement-assessments/[id=uuid]/edit/+page.server.ts index 2be95e97e..05a8fb4a0 100644 --- a/frontend/src/routes/(app)/(third-party)/requirement-assessments/[id=uuid]/edit/+page.server.ts +++ b/frontend/src/routes/(app)/(third-party)/requirement-assessments/[id=uuid]/edit/+page.server.ts @@ -29,14 +29,14 @@ export const load = (async ({ fetch, params }) => { } const requirementAssessment = await fetchJson(endpoint); + console.log(endpoint); + console.log(requirementAssessment); const requirement = requirementAssessment.requirement; const compliance_assessment_score = await fetchJson( `${baseUrl}/compliance-assessments/${requirementAssessment.compliance_assessment.id}/global_score/` ); - const parent = await fetchJson( - `${baseUrl}/requirement-nodes/?urn=${requirement.parent_urn}` - ).then((res) => res.results[0]); + const parent = requirementAssessment.requirement.parent_requirement const model = getModelInfo(URLModel); const object = { ...requirementAssessment }; diff --git a/frontend/src/routes/(app)/(third-party)/requirement-assessments/[id=uuid]/edit/+page.svelte b/frontend/src/routes/(app)/(third-party)/requirement-assessments/[id=uuid]/edit/+page.svelte index c9da5a0f9..5cbcc1e6a 100644 --- a/frontend/src/routes/(app)/(third-party)/requirement-assessments/[id=uuid]/edit/+page.svelte +++ b/frontend/src/routes/(app)/(third-party)/requirement-assessments/[id=uuid]/edit/+page.svelte @@ -6,13 +6,13 @@ export let data: PageData; export let form: ActionData; - const threats = data.requirement.threats; - const reference_controls = data.requirement.reference_controls; + const threats = data.requirementAssessment.requirement.associated_threats ?? []; + const reference_controls = data.requirementAssessment.requirement.associated_reference_controls ?? []; const annotation = data.requirement.annotation; const typical_evidence = data.requirement.typical_evidence; - const has_threats = threats && threats.length > 0; - const has_reference_controls = reference_controls && reference_controls.length > 0; + const has_threats = threats.length > 0; + const has_reference_controls = reference_controls.length > 0; import { page } from '$app/stores'; import AutocompleteSelect from '$lib/components/Forms/AutocompleteSelect.svelte'; From 2196e00e44d3ec89e60464b65b3cd35789f90121 Mon Sep 17 00:00:00 2001 From: Mohamed-Hacene Date: Wed, 27 Nov 2024 16:10:08 +0100 Subject: [PATCH 03/10] chore: run format --- backend/core/models.py | 8 ++++---- backend/core/serializers.py | 14 +++++++++++++- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/backend/core/models.py b/backend/core/models.py index ef37115a1..6ce373d54 100644 --- a/backend/core/models.py +++ b/backend/core/models.py @@ -1048,7 +1048,7 @@ class RequirementNode(ReferentialObjectMixin, I18nObjectMixin): null=True, blank=True, verbose_name=_("Typical evidence") ) question = models.JSONField(blank=True, null=True, verbose_name=_("Question")) - + @property def associated_reference_controls(self): _reference_controls = self.reference_controls.all() @@ -1058,7 +1058,7 @@ def associated_reference_controls(self): {"str": control.display_long, "urn": control.urn, "id": control.id} ) return reference_controls - + @property def associated_threats(self): _threats = self.threats.all() @@ -1068,7 +1068,7 @@ def associated_threats(self): {"str": control.display_long, "urn": control.urn, "id": control.id} ) return threats - + @property def parent_requirement(self): parent_requirement = RequirementNode.objects.filter(urn=self.parent_urn).first() @@ -1080,7 +1080,7 @@ def parent_requirement(self): "id": parent_requirement.id, "ref_id": parent_requirement.ref_id, "name": parent_requirement.name, - "description": parent_requirement.description + "description": parent_requirement.description, } class Meta: diff --git a/backend/core/serializers.py b/backend/core/serializers.py index da0c3e1e0..413e40497 100644 --- a/backend/core/serializers.py +++ b/backend/core/serializers.py @@ -613,7 +613,19 @@ class RequirementAssessmentReadSerializer(BaseModelSerializer): compliance_assessment = FieldsRelatedField() folder = FieldsRelatedField() assessable = serializers.BooleanField(source="requirement.assessable") - requirement = FieldsRelatedField(["urn", "annotation", "name", "description", "typical_evidence", "ref_id", "associated_reference_controls", "associated_threats", "parent_requirement"]) + requirement = FieldsRelatedField( + [ + "urn", + "annotation", + "name", + "description", + "typical_evidence", + "ref_id", + "associated_reference_controls", + "associated_threats", + "parent_requirement", + ] + ) class Meta: model = RequirementAssessment From cca4fd714cb80d8524455843131c7e9237fddae6 Mon Sep 17 00:00:00 2001 From: Mohamed-Hacene Date: Wed, 27 Nov 2024 16:17:39 +0100 Subject: [PATCH 04/10] feat: remove requirement node view for third parties --- backend/core/startup.py | 1 - 1 file changed, 1 deletion(-) diff --git a/backend/core/startup.py b/backend/core/startup.py index 0b5294dc5..f3faad47d 100644 --- a/backend/core/startup.py +++ b/backend/core/startup.py @@ -345,7 +345,6 @@ "view_complianceassessment", "view_requirementassessment", "change_requirementassessment", - "view_requirementnode", "view_evidence", "add_evidence", "change_evidence", From 28c50ce0edad0514760c5c44f034135e26abba44 Mon Sep 17 00:00:00 2001 From: Mohamed-Hacene Date: Wed, 27 Nov 2024 16:18:06 +0100 Subject: [PATCH 05/10] fix: add evidence in enclave from evidence list view --- frontend/src/lib/utils/crud.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/lib/utils/crud.ts b/frontend/src/lib/utils/crud.ts index 5e6be76e5..2d357cf6e 100644 --- a/frontend/src/lib/utils/crud.ts +++ b/frontend/src/lib/utils/crud.ts @@ -420,7 +420,7 @@ export const URL_MODEL_MAP: ModelMap = { verboseNamePlural: 'Evidences', fileFields: ['attachment'], foreignKeyFields: [ - { field: 'folder', urlModel: 'folders', urlParams: 'content_type=DO&content_type=GL' }, + { field: 'folder', urlModel: 'folders', urlParams: 'content_type=DO&content_type=GL&content_type=EN' }, { field: 'applied_controls', urlModel: 'applied-controls' } ] }, From a08367f439c6b492b5862856529494c757092af3 Mon Sep 17 00:00:00 2001 From: Mohamed-Hacene Date: Wed, 27 Nov 2024 16:30:32 +0100 Subject: [PATCH 06/10] chore: run format --- frontend/src/lib/utils/crud.ts | 6 +++++- .../requirement-assessments/[id=uuid]/edit/+page.server.ts | 2 +- .../requirement-assessments/[id=uuid]/edit/+page.svelte | 3 ++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/frontend/src/lib/utils/crud.ts b/frontend/src/lib/utils/crud.ts index 2d357cf6e..8b3ef7458 100644 --- a/frontend/src/lib/utils/crud.ts +++ b/frontend/src/lib/utils/crud.ts @@ -420,7 +420,11 @@ export const URL_MODEL_MAP: ModelMap = { verboseNamePlural: 'Evidences', fileFields: ['attachment'], foreignKeyFields: [ - { field: 'folder', urlModel: 'folders', urlParams: 'content_type=DO&content_type=GL&content_type=EN' }, + { + field: 'folder', + urlModel: 'folders', + urlParams: 'content_type=DO&content_type=GL&content_type=EN' + }, { field: 'applied_controls', urlModel: 'applied-controls' } ] }, diff --git a/frontend/src/routes/(app)/(third-party)/requirement-assessments/[id=uuid]/edit/+page.server.ts b/frontend/src/routes/(app)/(third-party)/requirement-assessments/[id=uuid]/edit/+page.server.ts index 05a8fb4a0..5ff6cb8b7 100644 --- a/frontend/src/routes/(app)/(third-party)/requirement-assessments/[id=uuid]/edit/+page.server.ts +++ b/frontend/src/routes/(app)/(third-party)/requirement-assessments/[id=uuid]/edit/+page.server.ts @@ -36,7 +36,7 @@ export const load = (async ({ fetch, params }) => { `${baseUrl}/compliance-assessments/${requirementAssessment.compliance_assessment.id}/global_score/` ); - const parent = requirementAssessment.requirement.parent_requirement + const parent = requirementAssessment.requirement.parent_requirement; const model = getModelInfo(URLModel); const object = { ...requirementAssessment }; diff --git a/frontend/src/routes/(app)/(third-party)/requirement-assessments/[id=uuid]/edit/+page.svelte b/frontend/src/routes/(app)/(third-party)/requirement-assessments/[id=uuid]/edit/+page.svelte index 5cbcc1e6a..9758d2c76 100644 --- a/frontend/src/routes/(app)/(third-party)/requirement-assessments/[id=uuid]/edit/+page.svelte +++ b/frontend/src/routes/(app)/(third-party)/requirement-assessments/[id=uuid]/edit/+page.svelte @@ -7,7 +7,8 @@ export let form: ActionData; const threats = data.requirementAssessment.requirement.associated_threats ?? []; - const reference_controls = data.requirementAssessment.requirement.associated_reference_controls ?? []; + const reference_controls = + data.requirementAssessment.requirement.associated_reference_controls ?? []; const annotation = data.requirement.annotation; const typical_evidence = data.requirement.typical_evidence; From 04ca202beb64b37a1d920ce2702ecb60ad163d5e Mon Sep 17 00:00:00 2001 From: Mohamed-Hacene Date: Wed, 27 Nov 2024 17:52:33 +0100 Subject: [PATCH 07/10] fix: api tests --- .../api/test_api_requirement_assessments.py | 42 ++++++++++++++++++- backend/core/serializers.py | 1 + .../[id=uuid]/edit/+page.server.ts | 2 - 3 files changed, 41 insertions(+), 4 deletions(-) diff --git a/backend/app_tests/api/test_api_requirement_assessments.py b/backend/app_tests/api/test_api_requirement_assessments.py index ef49c83e1..0623212de 100644 --- a/backend/app_tests/api/test_api_requirement_assessments.py +++ b/backend/app_tests/api/test_api_requirement_assessments.py @@ -124,7 +124,26 @@ def test_get_requirement_assessments(self, test): "id": str(compliance_assessment.id), "str": compliance_assessment.name, }, - "requirement": str(RequirementNode.objects.all()[0].id), + "requirement": { + "str": str(RequirementNode.objects.all()[0]), + "id": str(RequirementNode.objects.all()[0].id), + "urn": RequirementNode.objects.all()[0].urn, + "annotation": RequirementNode.objects.all()[0].annotation, + "name": RequirementNode.objects.all()[0].name, + "description": RequirementNode.objects.all()[0].description, + "typical_evidence": RequirementNode.objects.all()[0].typical_evidence, + "ref_id": RequirementNode.objects.all()[0].ref_id, + "associated_reference_controls": RequirementNode.objects.all()[0].associated_reference_controls, + "associated_threats": RequirementNode.objects.all()[0].associated_threats, + "parent_requirement": { + "str": RequirementNode.objects.all()[0].parent_requirement.get("str"), + "urn": RequirementNode.objects.all()[0].parent_requirement.get("urn"), + "id": str(RequirementNode.objects.all()[0].parent_requirement.get("id")), + "ref_id": RequirementNode.objects.all()[0].parent_requirement.get("ref_id"), + "name": RequirementNode.objects.all()[0].parent_requirement.get("name"), + "description": RequirementNode.objects.all()[0].parent_requirement.get("description"), + } if RequirementNode.objects.all()[0].parent_requirement else None, + }, }, base_count=-1, user_group=test.user_group, @@ -210,7 +229,26 @@ def test_update_requirement_assessments(self, test): "id": str(compliance_assessment.id), "str": compliance_assessment.name, }, - "requirement": str(RequirementNode.objects.all()[0].id), + "requirement": { + "str": str(RequirementNode.objects.all()[0]), + "id": str(RequirementNode.objects.all()[0].id), + "urn": RequirementNode.objects.all()[0].urn, + "annotation": RequirementNode.objects.all()[0].annotation, + "name": RequirementNode.objects.all()[0].name, + "description": RequirementNode.objects.all()[0].description, + "typical_evidence": RequirementNode.objects.all()[0].typical_evidence, + "ref_id": RequirementNode.objects.all()[0].ref_id, + "associated_reference_controls": RequirementNode.objects.all()[0].associated_reference_controls, + "associated_threats": RequirementNode.objects.all()[0].associated_threats, + "parent_requirement": { + "str": RequirementNode.objects.all()[0].parent_requirement.get("str"), + "urn": RequirementNode.objects.all()[0].parent_requirement.get("urn"), + "id": str(RequirementNode.objects.all()[0].parent_requirement.get("id")), + "ref_id": RequirementNode.objects.all()[0].parent_requirement.get("ref_id"), + "name": RequirementNode.objects.all()[0].parent_requirement.get("name"), + "description": RequirementNode.objects.all()[0].parent_requirement.get("description"), + } if RequirementNode.objects.all()[0].parent_requirement else None, + }, }, user_group=test.user_group, ) diff --git a/backend/core/serializers.py b/backend/core/serializers.py index 413e40497..6771fd4ce 100644 --- a/backend/core/serializers.py +++ b/backend/core/serializers.py @@ -615,6 +615,7 @@ class RequirementAssessmentReadSerializer(BaseModelSerializer): assessable = serializers.BooleanField(source="requirement.assessable") requirement = FieldsRelatedField( [ + "id", "urn", "annotation", "name", diff --git a/frontend/src/routes/(app)/(third-party)/requirement-assessments/[id=uuid]/edit/+page.server.ts b/frontend/src/routes/(app)/(third-party)/requirement-assessments/[id=uuid]/edit/+page.server.ts index 5ff6cb8b7..08e68fed1 100644 --- a/frontend/src/routes/(app)/(third-party)/requirement-assessments/[id=uuid]/edit/+page.server.ts +++ b/frontend/src/routes/(app)/(third-party)/requirement-assessments/[id=uuid]/edit/+page.server.ts @@ -29,8 +29,6 @@ export const load = (async ({ fetch, params }) => { } const requirementAssessment = await fetchJson(endpoint); - console.log(endpoint); - console.log(requirementAssessment); const requirement = requirementAssessment.requirement; const compliance_assessment_score = await fetchJson( `${baseUrl}/compliance-assessments/${requirementAssessment.compliance_assessment.id}/global_score/` From ea572b159e655b3cef92048738178ad7b5ed8b16 Mon Sep 17 00:00:00 2001 From: Mohamed-Hacene Date: Wed, 27 Nov 2024 17:53:49 +0100 Subject: [PATCH 08/10] chore: typo in api tests --- .../api/test_api_requirement_assessments.py | 84 ++++++++++++++----- 1 file changed, 64 insertions(+), 20 deletions(-) diff --git a/backend/app_tests/api/test_api_requirement_assessments.py b/backend/app_tests/api/test_api_requirement_assessments.py index 0623212de..12dad4661 100644 --- a/backend/app_tests/api/test_api_requirement_assessments.py +++ b/backend/app_tests/api/test_api_requirement_assessments.py @@ -131,18 +131,40 @@ def test_get_requirement_assessments(self, test): "annotation": RequirementNode.objects.all()[0].annotation, "name": RequirementNode.objects.all()[0].name, "description": RequirementNode.objects.all()[0].description, - "typical_evidence": RequirementNode.objects.all()[0].typical_evidence, + "typical_evidence": RequirementNode.objects.all()[ + 0 + ].typical_evidence, "ref_id": RequirementNode.objects.all()[0].ref_id, - "associated_reference_controls": RequirementNode.objects.all()[0].associated_reference_controls, - "associated_threats": RequirementNode.objects.all()[0].associated_threats, + "associated_reference_controls": RequirementNode.objects.all()[ + 0 + ].associated_reference_controls, + "associated_threats": RequirementNode.objects.all()[ + 0 + ].associated_threats, "parent_requirement": { - "str": RequirementNode.objects.all()[0].parent_requirement.get("str"), - "urn": RequirementNode.objects.all()[0].parent_requirement.get("urn"), - "id": str(RequirementNode.objects.all()[0].parent_requirement.get("id")), - "ref_id": RequirementNode.objects.all()[0].parent_requirement.get("ref_id"), - "name": RequirementNode.objects.all()[0].parent_requirement.get("name"), - "description": RequirementNode.objects.all()[0].parent_requirement.get("description"), - } if RequirementNode.objects.all()[0].parent_requirement else None, + "str": RequirementNode.objects.all()[0].parent_requirement.get( + "str" + ), + "urn": RequirementNode.objects.all()[0].parent_requirement.get( + "urn" + ), + "id": str( + RequirementNode.objects.all()[0].parent_requirement.get( + "id" + ) + ), + "ref_id": RequirementNode.objects.all()[ + 0 + ].parent_requirement.get("ref_id"), + "name": RequirementNode.objects.all()[0].parent_requirement.get( + "name" + ), + "description": RequirementNode.objects.all()[ + 0 + ].parent_requirement.get("description"), + } + if RequirementNode.objects.all()[0].parent_requirement + else None, }, }, base_count=-1, @@ -236,18 +258,40 @@ def test_update_requirement_assessments(self, test): "annotation": RequirementNode.objects.all()[0].annotation, "name": RequirementNode.objects.all()[0].name, "description": RequirementNode.objects.all()[0].description, - "typical_evidence": RequirementNode.objects.all()[0].typical_evidence, + "typical_evidence": RequirementNode.objects.all()[ + 0 + ].typical_evidence, "ref_id": RequirementNode.objects.all()[0].ref_id, - "associated_reference_controls": RequirementNode.objects.all()[0].associated_reference_controls, - "associated_threats": RequirementNode.objects.all()[0].associated_threats, + "associated_reference_controls": RequirementNode.objects.all()[ + 0 + ].associated_reference_controls, + "associated_threats": RequirementNode.objects.all()[ + 0 + ].associated_threats, "parent_requirement": { - "str": RequirementNode.objects.all()[0].parent_requirement.get("str"), - "urn": RequirementNode.objects.all()[0].parent_requirement.get("urn"), - "id": str(RequirementNode.objects.all()[0].parent_requirement.get("id")), - "ref_id": RequirementNode.objects.all()[0].parent_requirement.get("ref_id"), - "name": RequirementNode.objects.all()[0].parent_requirement.get("name"), - "description": RequirementNode.objects.all()[0].parent_requirement.get("description"), - } if RequirementNode.objects.all()[0].parent_requirement else None, + "str": RequirementNode.objects.all()[0].parent_requirement.get( + "str" + ), + "urn": RequirementNode.objects.all()[0].parent_requirement.get( + "urn" + ), + "id": str( + RequirementNode.objects.all()[0].parent_requirement.get( + "id" + ) + ), + "ref_id": RequirementNode.objects.all()[ + 0 + ].parent_requirement.get("ref_id"), + "name": RequirementNode.objects.all()[0].parent_requirement.get( + "name" + ), + "description": RequirementNode.objects.all()[ + 0 + ].parent_requirement.get("description"), + } + if RequirementNode.objects.all()[0].parent_requirement + else None, }, }, user_group=test.user_group, From 867dbedbb25d0dd1892dc50aa0afccf7a1e5d579 Mon Sep 17 00:00:00 2001 From: Mohamed-Hacene Date: Fri, 29 Nov 2024 15:37:10 +0100 Subject: [PATCH 09/10] feat: update read view of a requirement --- .../requirement-assessments/[id=uuid]/+page.server.ts | 9 ++------- .../requirement-assessments/[id=uuid]/+page.svelte | 9 +++++---- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/frontend/src/routes/(app)/(third-party)/requirement-assessments/[id=uuid]/+page.server.ts b/frontend/src/routes/(app)/(third-party)/requirement-assessments/[id=uuid]/+page.server.ts index acb0fb1c7..177c5ff37 100644 --- a/frontend/src/routes/(app)/(third-party)/requirement-assessments/[id=uuid]/+page.server.ts +++ b/frontend/src/routes/(app)/(third-party)/requirement-assessments/[id=uuid]/+page.server.ts @@ -12,13 +12,8 @@ export const load = (async ({ fetch, params }) => { const complianceAssessmentScore = await fetch( `${BASE_API_URL}/compliance-assessments/${requirementAssessment.compliance_assessment.id}/global_score/` ).then((res) => res.json()); - const requirement = await fetch( - `${BASE_API_URL}/requirement-nodes/${requirementAssessment.requirement}/` - ).then((res) => res.json()); - const parentRequirementNodeEndpoint = `${BASE_API_URL}/requirement-nodes/?urn=${requirement.parent_urn}`; - const parent = await fetch(parentRequirementNodeEndpoint) - .then((res) => res.json()) - .then((res) => res.results[0]); + const requirement = requirementAssessment.requirement; + const parent = requirementAssessment.requirement.parent_requirement; const tables: Record = {}; diff --git a/frontend/src/routes/(app)/(third-party)/requirement-assessments/[id=uuid]/+page.svelte b/frontend/src/routes/(app)/(third-party)/requirement-assessments/[id=uuid]/+page.svelte index 7f757b20c..7ac137a23 100644 --- a/frontend/src/routes/(app)/(third-party)/requirement-assessments/[id=uuid]/+page.svelte +++ b/frontend/src/routes/(app)/(third-party)/requirement-assessments/[id=uuid]/+page.svelte @@ -12,13 +12,14 @@ import { page } from '$app/stores'; export let data: PageData; - const threats = data.requirement.threats; - const reference_controls = data.requirement.reference_controls; + const threats = data.requirementAssessment.requirement.associated_threats ?? []; + const reference_controls = + data.requirementAssessment.requirement.associated_reference_controls ?? []; const annotation = data.requirement.annotation; const typical_evidence = data.requirement.typical_evidence; - const has_threats = threats && threats.length > 0; - const has_reference_controls = reference_controls && reference_controls.length > 0; + const has_threats = threats.length > 0; + const has_reference_controls = reference_controls.length > 0; $: mappingInference = { sourceRequirementAssessment: From 10ae3825a4cc508b44a9da0370e89c5e9972bc4c Mon Sep 17 00:00:00 2001 From: Mohamed-Hacene Date: Fri, 29 Nov 2024 16:20:42 +0100 Subject: [PATCH 10/10] fix: flash mode --- .../compliance-assessments/[id=uuid]/flash-mode/+page.svelte | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/routes/(app)/(internal)/compliance-assessments/[id=uuid]/flash-mode/+page.svelte b/frontend/src/routes/(app)/(internal)/compliance-assessments/[id=uuid]/flash-mode/+page.svelte index 76913b580..8b0dae806 100644 --- a/frontend/src/routes/(app)/(internal)/compliance-assessments/[id=uuid]/flash-mode/+page.svelte +++ b/frontend/src/routes/(app)/(internal)/compliance-assessments/[id=uuid]/flash-mode/+page.svelte @@ -26,7 +26,7 @@ const requirementHashmap = Object.fromEntries( data.requirements.map((requirement) => [requirement.id, requirement]) ); - $: requirement = requirementHashmap[currentRequirementAssessment.requirement]; + $: requirement = requirementHashmap[currentRequirementAssessment.requirement.id]; $: parent = data.requirements.find((req) => req.urn === requirement.parent_urn); $: title = requirement.display_short