From 0e97a4a4ea29b4cc2ebf9cf7edba2ff6e87bbe8e Mon Sep 17 00:00:00 2001 From: monsieurswag Date: Wed, 11 Sep 2024 12:12:34 +0200 Subject: [PATCH 1/2] Fix risk scenario tag translation --- backend/core/serializers.py | 2 +- frontend/src/lib/utils/crud.ts | 10 +++++----- .../[id=uuid]/remediation-plan/+page.svelte | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/backend/core/serializers.py b/backend/core/serializers.py index fac6fff35..74ffd00a2 100644 --- a/backend/core/serializers.py +++ b/backend/core/serializers.py @@ -275,7 +275,7 @@ class RiskScenarioReadSerializer(RiskScenarioWriteSerializer): threats = FieldsRelatedField(many=True) assets = FieldsRelatedField(many=True) - treatment = serializers.CharField(source="get_treatment_display") + treatment = serializers.CharField() current_proba = serializers.JSONField(source="get_current_proba") current_impact = serializers.JSONField(source="get_current_impact") diff --git a/frontend/src/lib/utils/crud.ts b/frontend/src/lib/utils/crud.ts index 5bd78f49d..da9cf3434 100644 --- a/frontend/src/lib/utils/crud.ts +++ b/frontend/src/lib/utils/crud.ts @@ -510,11 +510,11 @@ export const FIELD_COLORED_TAG_MAP: FieldColoredTagMap = { name: { key: 'treatment', values: { - Open: { text: 'open', cssClasses: 'badge bg-green-300' }, - Mitigate: { text: 'mitigate', cssClasses: 'badge bg-lime-200' }, - Accept: { text: 'accept', cssClasses: 'badge bg-green-200' }, - Avoid: { text: 'avoid', cssClasses: 'badge bg-red-200' }, - Transfer: { text: 'transfer', cssClasses: 'badge bg-yellow-300' } + open: { text: 'open', cssClasses: 'badge bg-green-300' }, + mitigate: { text: 'mitigate', cssClasses: 'badge bg-lime-200' }, + accept: { text: 'accept', cssClasses: 'badge bg-green-200' }, + avoid: { text: 'avoid', cssClasses: 'badge bg-red-200' }, + transfer: { text: 'transfer', cssClasses: 'badge bg-yellow-300' } } } }, diff --git a/frontend/src/routes/(app)/risk-assessments/[id=uuid]/remediation-plan/+page.svelte b/frontend/src/routes/(app)/risk-assessments/[id=uuid]/remediation-plan/+page.svelte index f33d1a983..83e6ad2a7 100644 --- a/frontend/src/routes/(app)/risk-assessments/[id=uuid]/remediation-plan/+page.svelte +++ b/frontend/src/routes/(app)/risk-assessments/[id=uuid]/remediation-plan/+page.svelte @@ -17,7 +17,7 @@ avoid: 'bg-red-200', transfer: 'bg-violet-200' }; - return map[status.toLowerCase()] ?? 'bg-gray-200'; + return map[status] ?? 'bg-gray-200'; }; const measureStatusColorMap = (treatment: string) => { @@ -68,7 +68,7 @@ href="/risk-scenarios/{scenario.id}">{scenario.name} {scenario.treatment}{safeTranslate(scenario.treatment)} From fb6a4b0f3279f27207fd2471cbd2ed13ada3d221 Mon Sep 17 00:00:00 2001 From: monsieurswag Date: Wed, 11 Sep 2024 16:10:13 +0200 Subject: [PATCH 2/2] Attempt to fix API tests --- backend/app_tests/api/test_api_risk_scenarios.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/app_tests/api/test_api_risk_scenarios.py b/backend/app_tests/api/test_api_risk_scenarios.py index 5146359a2..d0c6a30ee 100644 --- a/backend/app_tests/api/test_api_risk_scenarios.py +++ b/backend/app_tests/api/test_api_risk_scenarios.py @@ -110,8 +110,8 @@ "description": "acceptable risk", "hexcolor": "#00FF00", } -RISK_SCENARIO_TREATMENT_STATUS = ("accept", "Accept") -RISK_SCENARIO_TREATMENT_STATUS2 = ("mitigate", "Mitigate") +RISK_SCENARIO_TREATMENT_STATUS = ("accept", "accept") +RISK_SCENARIO_TREATMENT_STATUS2 = ("mitigate", "mitigate") RISK_SCENARIO_JUSTIFICATION = "Test justification"