Skip to content

Commit 619b2d7

Browse files
feat: Choose the domain of applied controls created from an audit (#2784)
* feat: Choose the domain of applied controls created from an audit * Fix broken domain selection for applied control creation * fix syntax * Use scope_folder_id for subdomain filtering --------- Co-authored-by: Nassim Tabchiche <[email protected]>
1 parent 4eba7e8 commit 619b2d7

File tree

6 files changed

+15
-4
lines changed

6 files changed

+15
-4
lines changed

backend/core/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4887,7 +4887,7 @@ class Meta:
48874887
# risk_matrix = self.risk_assessment.risk_matrix.parse_json()
48884888
# return [(k, v) for k, v in risk_matrix.fields[field].items()]
48894889

4890-
def get_folder_full_path(self, include_root: bool = False) -> list[Folder]:
4890+
def get_folder_full_path(self, *, include_root: bool = False) -> list[Folder]:
48914891
return self.risk_assessment.get_folder_full_path(include_root=include_root)
48924892

48934893
@property

backend/iam/models.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ def get_parent_folders(self) -> Generator[Self, None, None]:
139139
while (current_folder := current_folder.parent_folder) is not None:
140140
yield current_folder
141141

142-
def get_folder_full_path(self, include_root: bool = False) -> list[Self]:
142+
def get_folder_full_path(self, *, include_root: bool = False) -> list[Self]:
143143
"""
144144
Get the full path of the folder including its parents.
145145
If include_root is True, the root folder is included in the path.
@@ -328,7 +328,7 @@ class FolderMixin(models.Model):
328328
default=Folder.get_root_folder_id,
329329
)
330330

331-
def get_folder_full_path(self, include_root: bool = False) -> list[Folder]:
331+
def get_folder_full_path(self, *, include_root: bool = False) -> list[Folder]:
332332
folders = ([self.folder] + [f for f in self.folder.get_parent_folders()])[::-1]
333333
if include_root:
334334
return folders

frontend/src/lib/components/Forms/ModelForm.svelte

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@
9393
taintedMessage?: string | boolean;
9494
model: ModelInfo;
9595
context?: string;
96+
origin?: string | null;
9697
caching?: boolean;
9798
closeModal?: boolean;
9899
parent?: any;
@@ -113,6 +114,7 @@
113114
taintedMessage = m.taintedFormMessage(),
114115
model,
115116
context = 'default',
117+
origin = null,
116118
caching = false,
117119
closeModal = false,
118120
parent = {},
@@ -374,6 +376,7 @@
374376
{cacheLocks}
375377
{formDataCache}
376378
{schema}
379+
{origin}
377380
{initialData}
378381
{context}
379382
{...rest}

frontend/src/lib/components/Forms/ModelForm/AppliedControlPolicyForm.svelte

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
cacheLocks?: Record<string, CacheLock>;
2626
formDataCache?: Record<string, any>;
2727
schema?: any;
28+
origin?: string | null;
2829
initialData?: Record<string, any>;
2930
context?: string;
3031
rest?: Record<string, any>;
@@ -37,6 +38,7 @@
3738
cacheLocks = {},
3839
formDataCache = $bindable({}),
3940
schema = {},
41+
origin = null,
4042
initialData = {},
4143
context = 'default'
4244
}: Props = $props();
@@ -438,10 +440,12 @@
438440
<AutocompleteSelect
439441
{form}
440442
optionsEndpoint="folders?content_type=DO&content_type=GL"
443+
optionsDetailedUrlParameters={origin === 'requirement-assessments'
444+
? [['scope_folder_id', initialData.folder]]
445+
: []}
441446
field="folder"
442447
pathField="path"
443448
cacheLock={cacheLocks['folder']}
444449
bind:cachedValue={formDataCache['folder']}
445450
label={m.domain()}
446-
hidden={initialData.folder}
447451
/>

frontend/src/lib/components/Modals/CreateModal.svelte

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
invalidateAll?: boolean; // set to false to keep form data using muliple forms on a page
2727
formAction?: string;
2828
context?: string;
29+
origin?: string | null;
2930
additionalInitialData?: any;
3031
suggestions?: { [key: string]: any };
3132
taintedMessage?: string | boolean;
@@ -43,6 +44,7 @@
4344
invalidateAll = true,
4445
formAction = '?/create',
4546
context = 'create',
47+
origin = null,
4648
additionalInitialData = {},
4749
suggestions = {},
4850
taintedMessage = false,
@@ -87,6 +89,7 @@
8789
{model}
8890
{closeModal}
8991
{context}
92+
{origin}
9093
{duplicate}
9194
{taintedMessage}
9295
caching={true}

frontend/src/routes/(app)/(third-party)/requirement-assessments/[id=uuid]/edit/+page.svelte

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@
8585
model: data.measureModel,
8686
debug: false,
8787
invalidateAll: false,
88+
origin: 'requirement-assessments',
8889
suggestions: { reference_control: reference_controls }
8990
}
9091
};

0 commit comments

Comments
 (0)