From 0614bf3d38857b5159354aa66705bb0a1d089528 Mon Sep 17 00:00:00 2001 From: monsieurswag Date: Fri, 3 Jan 2025 07:28:26 +0100 Subject: [PATCH] Fix tests and too much permissive score copying --- backend/core/views.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/backend/core/views.py b/backend/core/views.py index 429b718a1..e2492f88d 100644 --- a/backend/core/views.py +++ b/backend/core/views.py @@ -2476,13 +2476,13 @@ def perform_create(self, serializer): ) instance: ComplianceAssessment = serializer.save() instance.create_requirement_assessments(baseline) - target_framework = serializer.validated_data["framework"] - source_framework = baseline.framework - same_minmax_score = ( - target_framework.min_score == source_framework.min_score - and target_framework.max_score == source_framework.max_score - ) if baseline and baseline.framework != instance.framework: + target_framework = serializer.validated_data["framework"] + source_framework = baseline.framework + same_minmax_score = ( + target_framework.min_score == source_framework.min_score + and target_framework.max_score == source_framework.max_score + ) mapping_set = RequirementMappingSet.objects.get( target_framework=target_framework, source_framework=baseline.framework, @@ -2497,7 +2497,7 @@ def perform_create(self, serializer): "source_requirement_assessment" ]["id"] ) - if same_minmax_score: + if same_minmax_score and target_framework == source_framework: requirement_assessment.is_scored = ( baseline_requirement_assessment.is_scored )