diff --git a/backend/ebios_rm/models.py b/backend/ebios_rm/models.py
index f51d4fc8b..a2d050858 100644
--- a/backend/ebios_rm/models.py
+++ b/backend/ebios_rm/models.py
@@ -137,6 +137,14 @@ def save(self, *args, **kwargs):
self.folder = self.ebios_rm_study.folder
super().save(*args, **kwargs)
+ @property
+ def risk_matrix(self):
+ return self.ebios_rm_study.risk_matrix
+
+ @property
+ def parsed_matrix(self):
+ return self.risk_matrix.parse_json_translated()
+
class RoTo(AbstractBaseModel, FolderMixin):
class RiskOrigin(models.TextChoices):
diff --git a/backend/ebios_rm/views.py b/backend/ebios_rm/views.py
index 1ca61f709..47cfac6b2 100644
--- a/backend/ebios_rm/views.py
+++ b/backend/ebios_rm/views.py
@@ -1,3 +1,4 @@
+from core.serializers import RiskMatrixReadSerializer
from core.views import BaseModelViewSet as AbstractBaseModelViewSet
from .models import (
EbiosRMStudy,
@@ -39,6 +40,25 @@ class FearedEventViewSet(BaseModelViewSet):
"ebios_rm_study",
]
+ @action(detail=True, name="Get risk matrix", url_path="risk-matrix")
+ def risk_matrix(self, request, pk=None):
+ feared_event = self.get_object()
+ return Response(RiskMatrixReadSerializer(feared_event.risk_matrix).data)
+
+ @method_decorator(cache_page(60 * LONG_CACHE_TTL))
+ @action(detail=True, name="Get gravity choices")
+ def gravity(self, request, pk):
+ feared_event: FearedEvent = self.get_object()
+ undefined = dict([(-1, "--")])
+ _choices = dict(
+ zip(
+ list(range(0, 64)),
+ [x["name"] for x in feared_event.parsed_matrix["impact"]],
+ )
+ )
+ choices = undefined | _choices
+ return Response(choices)
+
class RoToViewSet(BaseModelViewSet):
model = RoTo
diff --git a/frontend/messages/en.json b/frontend/messages/en.json
index ca6cab15a..77a6d510b 100644
--- a/frontend/messages/en.json
+++ b/frontend/messages/en.json
@@ -929,5 +929,6 @@
"impacts": "Impacts",
"ebiosRmStudies": "Ebios RM studies",
"bringTheEvidences": "Bring the evidences",
- "bringTheEvidencesHelpText": "If disabled, the object will be duplicated without its evidences"
+ "bringTheEvidencesHelpText": "If disabled, the object will be duplicated without its evidences",
+ "gravity": "Gravity"
}
diff --git a/frontend/src/lib/components/Forms/ModelForm/FearedEventForm.svelte b/frontend/src/lib/components/Forms/ModelForm/FearedEventForm.svelte
index d3548da56..9580233a3 100644
--- a/frontend/src/lib/components/Forms/ModelForm/FearedEventForm.svelte
+++ b/frontend/src/lib/components/Forms/ModelForm/FearedEventForm.svelte
@@ -32,6 +32,14 @@
cacheLock={cacheLocks['ref_id']}
bind:cachedValue={formDataCache['ref_id']}
/>
+