diff --git a/backend/core/migrations/0035_riskscenario_existing_applied_controls.py b/backend/core/migrations/0035_riskscenario_existing_applied_controls.py new file mode 100644 index 000000000..675d36503 --- /dev/null +++ b/backend/core/migrations/0035_riskscenario_existing_applied_controls.py @@ -0,0 +1,22 @@ +# Generated by Django 5.1.1 on 2024-11-09 08:49 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + dependencies = [ + ("core", "0034_fix_loaded_libraries_objects_meta"), + ] + + operations = [ + migrations.AddField( + model_name="riskscenario", + name="existing_applied_controls", + field=models.ManyToManyField( + blank=True, + related_name="risk_scenarios_e", + to="core.appliedcontrol", + verbose_name="Existing Applied controls", + ), + ), + ] diff --git a/backend/core/models.py b/backend/core/models.py index 1f8d09f34..aa0601909 100644 --- a/backend/core/models.py +++ b/backend/core/models.py @@ -1950,6 +1950,12 @@ class RiskScenario(NameDescriptionMixin): verbose_name=_("Existing controls"), blank=True, ) + existing_applied_controls = models.ManyToManyField( + AppliedControl, + verbose_name=_("Existing Applied controls"), + blank=True, + related_name="risk_scenarios_e", + ) owner = models.ManyToManyField( User, diff --git a/backend/core/serializers.py b/backend/core/serializers.py index 1fb812892..857f30afc 100644 --- a/backend/core/serializers.py +++ b/backend/core/serializers.py @@ -304,6 +304,7 @@ class RiskScenarioReadSerializer(RiskScenarioWriteSerializer): strength_of_knowledge = serializers.JSONField(source="get_strength_of_knowledge") applied_controls = FieldsRelatedField(many=True) + existing_applied_controls = FieldsRelatedField(many=True) rid = serializers.CharField() owner = FieldsRelatedField(many=True) diff --git a/frontend/src/lib/utils/schemas.ts b/frontend/src/lib/utils/schemas.ts index aac616d61..b84a05704 100644 --- a/frontend/src/lib/utils/schemas.ts +++ b/frontend/src/lib/utils/schemas.ts @@ -105,6 +105,7 @@ export const ThreatSchema = baseNamedObject({ export const RiskScenarioSchema = baseNamedObject({ existing_controls: z.string().optional(), applied_controls: z.string().uuid().optional().array().optional(), + existing_applied_controls: z.string().uuid().optional().array().optional(), current_proba: z.number().optional(), current_impact: z.number().optional(), residual_proba: z.number().optional(), diff --git a/frontend/src/routes/(app)/(internal)/risk-scenarios/[id=uuid]/edit/+page.svelte b/frontend/src/routes/(app)/(internal)/risk-scenarios/[id=uuid]/edit/+page.svelte index 9253fb967..abc35cc86 100644 --- a/frontend/src/routes/(app)/(internal)/risk-scenarios/[id=uuid]/edit/+page.svelte +++ b/frontend/src/routes/(app)/(internal)/risk-scenarios/[id=uuid]/edit/+page.svelte @@ -122,6 +122,7 @@ const impactColorMap = data.riskMatrix.impact.map((impact) => impact.hexcolor); +{@debug data}
-
-

{m.scope()}

-
- +
+
+

{m.project()}

{data.scenario.project.str} - - - -

{m.version()}

-

{data.scenario.version}

-
+
+
-

{m.status()}

-
-

{m.lastUpdate()}

-

- {new Date(data.scenario.updated_at).toLocaleString(languageTag())} -

-
-
+
-
+