diff --git a/backend/core/serializers.py b/backend/core/serializers.py index c8490d807..5d1602395 100644 --- a/backend/core/serializers.py +++ b/backend/core/serializers.py @@ -5,6 +5,7 @@ from core.models import * from iam.models import * +from ebios_rm.models import EbiosRMStudy from rest_framework import serializers from rest_framework.exceptions import PermissionDenied @@ -600,6 +601,14 @@ class ComplianceAssessmentWriteSerializer(BaseModelSerializer): required=False, allow_null=True, ) + ebios_rm_studies = serializers.SlugRelatedField( + many=True, + slug_field="id", + queryset=EbiosRMStudy.objects.all(), + required=False, + allow_null=True, + write_only=True, + ) create_applied_controls_from_suggestions = serializers.BooleanField( write_only=True, required=False, default=False ) @@ -712,3 +721,13 @@ class FilteringLabelWriteSerializer(BaseModelSerializer): class Meta: model = FilteringLabel exclude = ["folder", "is_published"] + + +class QualificationReadSerializer(ReferentialSerializer): + class Meta: + model = Qualification + exclude = ["translations"] + + +class QualificationWriteSerializer(QualificationReadSerializer): + pass diff --git a/backend/core/startup.py b/backend/core/startup.py index 37c06a1e5..3196379e2 100644 --- a/backend/core/startup.py +++ b/backend/core/startup.py @@ -363,6 +363,10 @@ "view_operationalscenario", "change_operationalscenario", "delete_operationalscenario", + "view_qualification", + "add_qualification", + "change_qualification", + "delete_qualification", ] THIRD_PARTY_RESPONDENT_PERMISSIONS_LIST = [ diff --git a/backend/core/urls.py b/backend/core/urls.py index 57b55901e..0b79a6c3c 100644 --- a/backend/core/urls.py +++ b/backend/core/urls.py @@ -66,6 +66,11 @@ FilteringLabelViewSet, basename="filtering-labels", ) +router.register( + r"qualifications", + QualificationViewSet, + basename="qualifications", +) ROUTES = settings.ROUTES MODULES = settings.MODULES.values() diff --git a/backend/core/views.py b/backend/core/views.py index d7c825dd7..858cf7118 100644 --- a/backend/core/views.py +++ b/backend/core/views.py @@ -358,7 +358,13 @@ class AssetViewSet(BaseModelViewSet): """ model = Asset - filterset_fields = ["folder", "parent_assets", "type", "risk_scenarios"] + filterset_fields = [ + "folder", + "parent_assets", + "type", + "risk_scenarios", + "ebios_rm_studies", + ] search_fields = ["name", "description", "business_value"] @action(detail=False, name="Get type choices") @@ -2025,13 +2031,22 @@ def post(self, request, *args, **kwargs): return Response(status=status.HTTP_400_BAD_REQUEST) +class QualificationViewSet(BaseModelViewSet): + """ + API endpoint that allows qualifications to be viewed or edited. + """ + + model = Qualification + search_fields = ["name"] + + class ComplianceAssessmentViewSet(BaseModelViewSet): """ API endpoint that allows compliance assessments to be viewed or edited. """ model = ComplianceAssessment - filterset_fields = ["framework", "project", "status"] + filterset_fields = ["framework", "project", "status", "ebios_rm_studies"] search_fields = ["name", "description", "ref_id"] ordering_fields = ["name", "description"] diff --git a/backend/ebios_rm/migrations/0001_initial.py b/backend/ebios_rm/migrations/0001_initial.py index 66af48c5f..8980b23f0 100644 --- a/backend/ebios_rm/migrations/0001_initial.py +++ b/backend/ebios_rm/migrations/0001_initial.py @@ -163,6 +163,7 @@ class Migration(migrations.Migration): related_name="ebios_rm_studies", to="core.riskmatrix", verbose_name="Risk matrix", + blank=True, ), ), ], diff --git a/backend/ebios_rm/models.py b/backend/ebios_rm/models.py index 99104508d..e0f39b2d4 100644 --- a/backend/ebios_rm/models.py +++ b/backend/ebios_rm/models.py @@ -31,6 +31,7 @@ class Status(models.TextChoices): help_text=_( "Risk matrix used as a reference for the study. Defaults to `urn:intuitem:risk:library:risk-matrix-4x4-ebios-rm`" ), + blank=True, ) assets = models.ManyToManyField( Asset, @@ -297,6 +298,9 @@ class Meta: verbose_name_plural = _("Stakeholders") ordering = ["created_at"] + def __str__(self): + return f"{self.entity.name} - {self.category}" + def save(self, *args, **kwargs): self.folder = self.ebios_rm_study.folder super().save(*args, **kwargs) diff --git a/backend/ebios_rm/serializers.py b/backend/ebios_rm/serializers.py index e77c5c153..fb435c502 100644 --- a/backend/ebios_rm/serializers.py +++ b/backend/ebios_rm/serializers.py @@ -71,8 +71,8 @@ class Meta: class FearedEventReadSerializer(BaseModelSerializer): - str = serializers.CharField(source="__str__") ebios_rm_study = FieldsRelatedField() + qualifications = FieldsRelatedField(["name"], many=True) folder = FieldsRelatedField() class Meta: @@ -107,7 +107,7 @@ class Meta: class StakeholderReadSerializer(BaseModelSerializer): - str = serializers.CharField(source="__str__") + name = serializers.CharField(source="__str__") ebios_rm_study = FieldsRelatedField() folder = FieldsRelatedField() entity = FieldsRelatedField() diff --git a/backend/ebios_rm/views.py b/backend/ebios_rm/views.py index ca0d048dd..1ca61f709 100644 --- a/backend/ebios_rm/views.py +++ b/backend/ebios_rm/views.py @@ -35,6 +35,10 @@ def status(self, request): class FearedEventViewSet(BaseModelViewSet): model = FearedEvent + filterset_fields = [ + "ebios_rm_study", + ] + class RoToViewSet(BaseModelViewSet): model = RoTo diff --git a/frontend/messages/en.json b/frontend/messages/en.json index 9d5b87a36..36eb51bca 100644 --- a/frontend/messages/en.json +++ b/frontend/messages/en.json @@ -921,6 +921,22 @@ "ebiosWs5_4": "Assess and document residual risks", "ebiosWs5_5": "Establish risk monitoring framework", "activity": "Activity", + "ebiosRmMatrixHelpText": "Risk matrix used as a reference for the study. Defaults to `urn:intuitem:risk:library:risk-matrix-4x4-ebios-rm`", + "activityOne": "Activity 1", + "activityTwo": "Activity 2", + "ebiosRmStudy": "Ebios RM study", + "qualifications": "Qualifications", + "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", + "currentDependency": "Current dependency", + "currentPenetration": "Current penetration", + "currentMaturity": "Current maturity", + "currentTrust": "Current trust", + "residualDependency": "Residual dependency", + "residualPenetration": "Residual penetration", + "residualMaturity": "Residual maturity", + "residualTrust": "Residual trust", + "selected": "Selected" } diff --git a/frontend/src/lib/components/Breadcrumbs/Breadcrumbs.svelte b/frontend/src/lib/components/Breadcrumbs/Breadcrumbs.svelte index 7ceac4475..ff92026a7 100644 --- a/frontend/src/lib/components/Breadcrumbs/Breadcrumbs.svelte +++ b/frontend/src/lib/components/Breadcrumbs/Breadcrumbs.svelte @@ -17,7 +17,7 @@ let tokenPath = ''; crumbs = tokens.map((t) => { tokenPath += '/' + t; - if (t === $breadcrumbObject.id) { + if (t === $breadcrumbObject?.id) { if ($breadcrumbObject.name) { t = $breadcrumbObject.name; } else if ($breadcrumbObject.first_name && $breadcrumbObject.last_name) { diff --git a/frontend/src/lib/components/Forms/ModelForm.svelte b/frontend/src/lib/components/Forms/ModelForm.svelte index da9c227a7..e97998148 100644 --- a/frontend/src/lib/components/Forms/ModelForm.svelte +++ b/frontend/src/lib/components/Forms/ModelForm.svelte @@ -26,6 +26,9 @@ import SsoSettingsForm from './ModelForm/SsoSettingForm.svelte'; import FolderForm from './ModelForm/FolderForm.svelte'; import GeneralSettingsForm from './ModelForm/GeneralSettingForm.svelte'; + import EbiosRmForm from './ModelForm/EbiosRmForm.svelte'; + import FearedEventForm from './ModelForm/FearedEventForm.svelte'; + import StakeholderForm from './ModelForm/StakeholderForm.svelte'; import AutocompleteSelect from './AutocompleteSelect.svelte'; @@ -255,6 +258,12 @@ {:else if URLModel === 'filtering-labels'} + {:else if URLModel === 'ebios-rm'} + + {:else if URLModel === 'feared-events'} + + {:else if URLModel === 'stakeholders'} + {/if}
{#if closeModal} diff --git a/frontend/src/lib/components/Forms/ModelForm/ComplianceAssessmentForm.svelte b/frontend/src/lib/components/Forms/ModelForm/ComplianceAssessmentForm.svelte index c53338fa0..0bba0a55c 100644 --- a/frontend/src/lib/components/Forms/ModelForm/ComplianceAssessmentForm.svelte +++ b/frontend/src/lib/components/Forms/ModelForm/ComplianceAssessmentForm.svelte @@ -38,6 +38,18 @@ options={getOptions({ objects: model.foreignKeys['baseline'] })} /> {/if} +{#if initialData.ebios_rm_studies} +