From 7c753e13eb8377b0c2ffaa3dae9a5aadd8f48855 Mon Sep 17 00:00:00 2001 From: Mohamed-Hacene Date: Fri, 6 Dec 2024 11:09:54 +0100 Subject: [PATCH 1/3] fix: duplicate scenario ref_id --- backend/core/views.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/backend/core/views.py b/backend/core/views.py index d7c825dd7..9aeefd33c 100644 --- a/backend/core/views.py +++ b/backend/core/views.py @@ -850,20 +850,21 @@ def duplicate(self, request, pk): residual_impact=scenario.residual_impact, strength_of_knowledge=scenario.strength_of_knowledge, justification=scenario.justification, + ref_id=scenario.ref_id, ) for field in ["applied_controls", "threats", "assets"]: duplicate_related_objects( scenario, duplicate_scenario, - duplicate_risk_assessment.project.folder, + duplicate_risk_assessment.folder, field, ) if ( - duplicate_risk_assessment.project.folder - in [risk_assessment.project.folder] - + risk_assessment.project.folder.sub_folders() + duplicate_risk_assessment.folder + in [risk_assessment.folder] + + [risk for risk in risk_assessment.folder.get_sub_folders()] ): duplicate_scenario.owner.set(scenario.owner.all()) From a45504e9e2d86c1d80ef5a4e3c28428c11941675 Mon Sep 17 00:00:00 2001 From: Mohamed-Hacene Date: Fri, 6 Dec 2024 11:11:09 +0100 Subject: [PATCH 2/3] fix: typos --- backend/core/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/core/views.py b/backend/core/views.py index 9aeefd33c..62117b838 100644 --- a/backend/core/views.py +++ b/backend/core/views.py @@ -864,7 +864,7 @@ def duplicate(self, request, pk): if ( duplicate_risk_assessment.folder in [risk_assessment.folder] - + [risk for risk in risk_assessment.folder.get_sub_folders()] + + [folder for folder in risk_assessment.folder.get_sub_folders()] ): duplicate_scenario.owner.set(scenario.owner.all()) From f67088f061057e3d67a9dcfbcc567d379f9635a2 Mon Sep 17 00:00:00 2001 From: Mohamed-Hacene Date: Fri, 6 Dec 2024 11:13:09 +0100 Subject: [PATCH 3/3] chore: format --- backend/core/views.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/backend/core/views.py b/backend/core/views.py index 62117b838..51d054ddf 100644 --- a/backend/core/views.py +++ b/backend/core/views.py @@ -861,11 +861,9 @@ def duplicate(self, request, pk): field, ) - if ( - duplicate_risk_assessment.folder - in [risk_assessment.folder] - + [folder for folder in risk_assessment.folder.get_sub_folders()] - ): + if duplicate_risk_assessment.folder in [risk_assessment.folder] + [ + folder for folder in risk_assessment.folder.get_sub_folders() + ]: duplicate_scenario.owner.set(scenario.owner.all()) duplicate_scenario.save()