diff --git a/backend/ebios_rm/migrations/0010_alter_ebiosrmstudy_risk_matrix.py b/backend/ebios_rm/migrations/0010_alter_ebiosrmstudy_risk_matrix.py new file mode 100644 index 000000000..a7085b5af --- /dev/null +++ b/backend/ebios_rm/migrations/0010_alter_ebiosrmstudy_risk_matrix.py @@ -0,0 +1,26 @@ +# Generated by Django 5.1.4 on 2024-12-21 18:37 + +import django.db.models.deletion +from django.db import migrations, models + + +class Migration(migrations.Migration): + dependencies = [ + ("core", "0046_riskassessment_ebios_rm_study"), + ("ebios_rm", "0009_alter_roto_activity"), + ] + + operations = [ + migrations.AlterField( + model_name="ebiosrmstudy", + name="risk_matrix", + field=models.ForeignKey( + blank=True, + help_text="Risk matrix used as a reference for the study", + on_delete=django.db.models.deletion.PROTECT, + related_name="ebios_rm_studies", + to="core.riskmatrix", + verbose_name="Risk matrix", + ), + ), + ] diff --git a/backend/ebios_rm/models.py b/backend/ebios_rm/models.py index 5b35766fc..6f5e32283 100644 --- a/backend/ebios_rm/models.py +++ b/backend/ebios_rm/models.py @@ -97,9 +97,7 @@ class Status(models.TextChoices): on_delete=models.PROTECT, verbose_name=_("Risk matrix"), related_name="ebios_rm_studies", - help_text=_( - "Risk matrix used as a reference for the study. Defaults to `urn:intuitem:risk:library:risk-matrix-4x4-ebios-rm`" - ), + help_text=_("Risk matrix used as a reference for the study"), blank=True, ) assets = models.ManyToManyField( diff --git a/backend/ebios_rm/serializers.py b/backend/ebios_rm/serializers.py index 6a9457242..2c0f15c33 100644 --- a/backend/ebios_rm/serializers.py +++ b/backend/ebios_rm/serializers.py @@ -21,28 +21,6 @@ class EbiosRMStudyWriteSerializer(BaseModelSerializer): queryset=RiskMatrix.objects.all(), required=False ) - def create(self, validated_data): - if not validated_data.get("risk_matrix"): - try: - ebios_matrix = RiskMatrix.objects.filter( - urn="urn:intuitem:risk:matrix:risk-matrix-4x4-ebios-rm" - ).first() - if not ebios_matrix: - ebios_matrix_library = StoredLibrary.objects.get( - urn="urn:intuitem:risk:library:risk-matrix-4x4-ebios-rm" - ) - ebios_matrix_library.load() - ebios_matrix = RiskMatrix.objects.get( - urn="urn:intuitem:risk:matrix:risk-matrix-4x4-ebios-rm" - ) - validated_data["risk_matrix"] = ebios_matrix - except (StoredLibrary.DoesNotExist, RiskMatrix.DoesNotExist) as e: - logging.error(f"Error loading risk matrix: {str(e)}") - raise serializers.ValidationError( - "An error occurred while loading the risk matrix." - ) - return super().create(validated_data) - class Meta: model = EbiosRMStudy exclude = ["created_at", "updated_at"] diff --git a/backend/library/libraries/risk-matrix-4x4-ebios-rm.yaml b/backend/library/libraries/risk-matrix-4x4-ebios-rm.yaml index 51ff10780..3febfb182 100644 --- a/backend/library/libraries/risk-matrix-4x4-ebios-rm.yaml +++ b/backend/library/libraries/risk-matrix-4x4-ebios-rm.yaml @@ -4,7 +4,7 @@ ref_id: risk-matrix-4x4-ebios-rm name: 4x4 risk matrix from EBIOS-RM description: based on the official guide of the EBIOS RM approach copyright: public domain -version: 2 +version: 3 provider: intuitem packager: intuitem translations: @@ -171,4 +171,5 @@ objects: - 2 translations: fr: + name: Matrice 4x4 EBIOS-RM description: "Bas\xE9e sur le guide officiel de la m\xE9thode EBIOS RM" diff --git a/enterprise/frontend/src/lib/components/Forms/ModelForm/EbiosRmForm.svelte b/enterprise/frontend/src/lib/components/Forms/ModelForm/EbiosRmForm.svelte index 17f64f811..20c712ef9 100644 --- a/enterprise/frontend/src/lib/components/Forms/ModelForm/EbiosRmForm.svelte +++ b/enterprise/frontend/src/lib/components/Forms/ModelForm/EbiosRmForm.svelte @@ -76,7 +76,7 @@ cacheLock={cacheLocks['risk_matrix']} bind:cachedValue={formDataCache['risk_matrix']} label={m.riskMatrix()} - placeholder={m.ebiosRmRiskMatrix()} + placeholder={m.riskAssessmentMatrixHelpText()} helpText={m.ebiosRmMatrixHelpText()} /> {:else if context === 'ebiosRmStudy'} diff --git a/frontend/messages/en.json b/frontend/messages/en.json index a57cf46b6..9c83871ce 100644 --- a/frontend/messages/en.json +++ b/frontend/messages/en.json @@ -924,7 +924,7 @@ "ebiosWs5_4": "Assess and document residual risks", "ebiosWs5_5": "Establish risk monitoring framework", "activity": "Step", - "ebiosRmMatrixHelpText": "Risk matrix used as a reference for the study. Defaults to `urn:intuitem:risk:library:risk-matrix-4x4-ebios-rm`", + "ebiosRmMatrixHelpText": "Risk matrix used as a reference for the study", "activityOne": "Step 1", "activityTwo": "Step 2", "activityThree": "Step 3", @@ -1014,7 +1014,6 @@ "addStrategicScenario": "Add strategic scenario", "markAsDone": "Mark as done", "markAsInProgress": "Mark as in progress", - "ebiosRmRiskMatrix": "4x4 risk matrix from EBIOS-RM", "riskAnalyses": "Risk analyses", "client": "Client", "partner": "Partner", diff --git a/frontend/messages/fr.json b/frontend/messages/fr.json index e09091651..6e8aa2a18 100644 --- a/frontend/messages/fr.json +++ b/frontend/messages/fr.json @@ -924,7 +924,7 @@ "ebiosWs5_4": "Évaluer et documenter les risques résiduels", "ebiosWs5_5": "Mettre en place le cadre de suivi des risques", "activity": "Activité", - "ebiosRmMatrixHelpText": "Matrice de risque utilisée pour l'étude. La valeur par défaut est `urn:intuitem:risk:library:risk-matrix-4x4-ebios-rm`", + "ebiosRmMatrixHelpText": "Matrice de risque utilisée pour l'étude.", "activityOne": "Activité 1", "activityTwo": "Activité 2", "activityThree": "Activité 3", diff --git a/frontend/src/lib/components/Forms/ModelForm/EbiosRmForm.svelte b/frontend/src/lib/components/Forms/ModelForm/EbiosRmForm.svelte index 82e9d11e7..d85c44fc0 100644 --- a/frontend/src/lib/components/Forms/ModelForm/EbiosRmForm.svelte +++ b/frontend/src/lib/components/Forms/ModelForm/EbiosRmForm.svelte @@ -67,7 +67,6 @@ cacheLock={cacheLocks['risk_matrix']} bind:cachedValue={formDataCache['risk_matrix']} label={m.riskMatrix()} - placeholder={m.ebiosRmRiskMatrix()} helpText={m.ebiosRmMatrixHelpText()} /> {:else if context === 'ebiosRmStudy'} diff --git a/frontend/src/lib/utils/schemas.ts b/frontend/src/lib/utils/schemas.ts index ded5499a4..2553a40cd 100644 --- a/frontend/src/lib/utils/schemas.ts +++ b/frontend/src/lib/utils/schemas.ts @@ -396,7 +396,7 @@ export const ebiosRMSchema = z.object({ ...NameDescriptionMixin, version: z.string().optional().default('0.1'), ref_id: z.string().optional().default(''), - risk_matrix: z.string().optional(), + risk_matrix: z.string(), authors: z.array(z.string().optional()).optional(), reviewers: z.array(z.string().optional()).optional(), observation: z.string().optional().nullable(), diff --git a/tools/matrix/risk-matrix-4x4-ebios-rm.xlsx b/tools/matrix/risk-matrix-4x4-ebios-rm.xlsx index cf8eddf15..169654dd8 100644 Binary files a/tools/matrix/risk-matrix-4x4-ebios-rm.xlsx and b/tools/matrix/risk-matrix-4x4-ebios-rm.xlsx differ