diff --git a/backend/core/models.py b/backend/core/models.py index 1b5267133..f3e148f16 100644 --- a/backend/core/models.py +++ b/backend/core/models.py @@ -2621,7 +2621,8 @@ def create_applied_controls_from_suggestions(self) -> list[AppliedControl]: exc_info=e, ) continue - self.applied_controls.set(applied_controls) + if applied_controls: + self.applied_controls.add(applied_controls) return applied_controls class Meta: diff --git a/backend/core/serializers.py b/backend/core/serializers.py index 1180b179b..85eca813f 100644 --- a/backend/core/serializers.py +++ b/backend/core/serializers.py @@ -479,6 +479,7 @@ class Meta: class FrameworkReadSerializer(ReferentialSerializer): folder = FieldsRelatedField() library = FieldsRelatedField(["name", "id"]) + reference_controls = FieldsRelatedField(many=True) class Meta: model = Framework diff --git a/frontend/src/lib/components/Forms/ModelForm/ComplianceAssessmentForm.svelte b/frontend/src/lib/components/Forms/ModelForm/ComplianceAssessmentForm.svelte index 6b77f02c5..bbfe2a9f3 100644 --- a/frontend/src/lib/components/Forms/ModelForm/ComplianceAssessmentForm.svelte +++ b/frontend/src/lib/components/Forms/ModelForm/ComplianceAssessmentForm.svelte @@ -16,6 +16,8 @@ export let initialData: Record = {}; export let object: any = {}; export let context: string; + + let suggestions = false; {#if context === 'fromBaseline' && initialData.baseline} @@ -72,6 +74,7 @@ model.selectOptions['selected_implementation_groups'] = implementation_groups.map( (group) => ({ label: group.name, value: group.ref_id }) ); + suggestions = r['reference_controls'].length > 0; }); } }} @@ -131,7 +134,7 @@ cacheLock={cacheLocks['observation']} bind:cachedValue={formDataCache['observation']} /> -{#if context === 'create'} +{#if context === 'create' && suggestions}