Skip to content

Commit

Permalink
Merge pull request #908 from intuitem/fix/suggested-controls-overwrit…
Browse files Browse the repository at this point in the history
…ten-when-adding-new-ones

Add suggested controls instead of setting them
  • Loading branch information
Mohamed-Hacene authored Oct 9, 2024
2 parents b04d99e + 4530206 commit be5ee6d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
3 changes: 2 additions & 1 deletion backend/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions backend/core/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,7 @@ class Meta:
class FrameworkReadSerializer(ReferentialSerializer):
folder = FieldsRelatedField()
library = FieldsRelatedField(["name", "id"])
reference_controls = FieldsRelatedField(many=True)

class Meta:
model = Framework
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
export let initialData: Record<string, any> = {};
export let object: any = {};
export let context: string;
let suggestions = false;
</script>

{#if context === 'fromBaseline' && initialData.baseline}
Expand Down Expand Up @@ -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;
});
}
}}
Expand Down Expand Up @@ -131,7 +134,7 @@
cacheLock={cacheLocks['observation']}
bind:cachedValue={formDataCache['observation']}
/>
{#if context === 'create'}
{#if context === 'create' && suggestions}
<Checkbox
{form}
field="create_applied_controls_from_suggestions"
Expand Down

0 comments on commit be5ee6d

Please sign in to comment.