diff --git a/backend/ebios_rm/migrations/0002_alter_roto_target_objective.py b/backend/ebios_rm/migrations/0002_alter_roto_target_objective.py new file mode 100644 index 000000000..2af2cfbd7 --- /dev/null +++ b/backend/ebios_rm/migrations/0002_alter_roto_target_objective.py @@ -0,0 +1,17 @@ +# Generated by Django 5.1.1 on 2024-12-06 14:51 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + dependencies = [ + ("ebios_rm", "0001_initial"), + ] + + operations = [ + migrations.AlterField( + model_name="roto", + name="target_objective", + field=models.TextField(verbose_name="Target objective"), + ), + ] diff --git a/backend/ebios_rm/models.py b/backend/ebios_rm/models.py index 30543cba9..044c6bc49 100644 --- a/backend/ebios_rm/models.py +++ b/backend/ebios_rm/models.py @@ -208,9 +208,7 @@ class Pertinence(models.IntegerChoices): risk_origin = models.CharField( max_length=32, verbose_name=_("Risk origin"), choices=RiskOrigin.choices ) - target_objective = models.CharField( - max_length=200, verbose_name=_("Target objective") - ) + target_objective = models.TextField(verbose_name=_("Target objective")) motivation = models.PositiveSmallIntegerField( verbose_name=_("Motivation"), choices=Motivation.choices, diff --git a/backend/ebios_rm/serializers.py b/backend/ebios_rm/serializers.py index 15da633fc..4b5a0d9d2 100644 --- a/backend/ebios_rm/serializers.py +++ b/backend/ebios_rm/serializers.py @@ -92,7 +92,11 @@ class RoToReadSerializer(BaseModelSerializer): str = serializers.CharField(source="__str__") ebios_rm_study = FieldsRelatedField() folder = FieldsRelatedField() - feared_events = FieldsRelatedField(many=True) + feared_events = FieldsRelatedField(["folder", "id"], many=True) + + pertinence = serializers.CharField(source="get_pertinence_display") + motivation = serializers.CharField(source="get_motivation_display") + resources = serializers.CharField(source="get_resources_display") class Meta: model = RoTo diff --git a/backend/ebios_rm/views.py b/backend/ebios_rm/views.py index af0360603..8fcaf6ce9 100644 --- a/backend/ebios_rm/views.py +++ b/backend/ebios_rm/views.py @@ -77,6 +77,10 @@ def gravity(self, request, pk): class RoToViewSet(BaseModelViewSet): model = RoTo + filterset_fields = [ + "ebios_rm_study", + ] + @action(detail=False, name="Get risk origin choices", url_path="risk-origin") def risk_origin(self, request): return Response(dict(RoTo.RiskOrigin.choices)) diff --git a/frontend/messages/en.json b/frontend/messages/en.json index 11b1f8bf3..a78f1bc0d 100644 --- a/frontend/messages/en.json +++ b/frontend/messages/en.json @@ -384,7 +384,7 @@ "exportDatabase": "Export database", "upload": "Upload", "add": "Add", - "undefined": "--", + "undefined": "undefined", "production": "Production", "design": "Design", "development": "Development", @@ -937,5 +937,28 @@ "fearedEvent": "Feared event", "fearedEvents": "Feared events", "isSelected": "Is selected", - "ebiosRM": "Ebios RM" + "ebiosRM": "Ebios RM", + "riskOrigin": "Risk origin", + "targetObjective": "Target objective", + "motivation": "Motivation", + "resources": "Resources", + "pertinence": "Pertinence", + "limited": "Limited", + "significant": "Significant", + "important": "Important", + "unlimited": "Unlimited", + "strong": "Strong", + "irrelevant": "Irrelevant", + "partiallyRelevant": "Partially relevant", + "fairlyRelevant": "Fairly relevant", + "highlyRelevant": "Highly relevant", + "roTo": "RO/TO", + "addRoto": "Add RO/TO couple", + "organizedCrime": "Organized crime", + "terrorist": "Terrorist", + "activist": "Activist", + "professional": "Professional", + "amateur": "Amateur", + "avenger": "Avenger", + "pathological": "Pathological" } diff --git a/frontend/src/lib/components/Forms/ModelForm.svelte b/frontend/src/lib/components/Forms/ModelForm.svelte index 7f30a2a71..3866c9d84 100644 --- a/frontend/src/lib/components/Forms/ModelForm.svelte +++ b/frontend/src/lib/components/Forms/ModelForm.svelte @@ -28,6 +28,7 @@ import GeneralSettingsForm from './ModelForm/GeneralSettingForm.svelte'; import EbiosRmForm from './ModelForm/EbiosRmForm.svelte'; import FearedEventForm from './ModelForm/FearedEventForm.svelte'; + import RoToForm from './ModelForm/RoToForm.svelte'; import AutocompleteSelect from './AutocompleteSelect.svelte'; @@ -261,6 +262,8 @@ {:else if URLModel === 'feared-events'} + {:else if URLModel === 'ro-to'} + {/if}
{#if closeModal} diff --git a/frontend/src/lib/components/Forms/ModelForm/RoToForm.svelte b/frontend/src/lib/components/Forms/ModelForm/RoToForm.svelte new file mode 100644 index 000000000..683e6accd --- /dev/null +++ b/frontend/src/lib/components/Forms/ModelForm/RoToForm.svelte @@ -0,0 +1,93 @@ + + +