Skip to content

Commit

Permalink
Remove useless argument
Browse files Browse the repository at this point in the history
  • Loading branch information
monsieurswag committed Oct 17, 2024
1 parent abc33a5 commit 4ceed7c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
8 changes: 4 additions & 4 deletions backend/core/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1182,17 +1182,15 @@ def duplicate_related_objects(
duplicate_object: models.Model,
target_folder: Folder,
field_name: str,
model_class: Type[models.Model],
):
"""
Duplicates related objects from a source object to a duplicate object, avoiding duplicates in the target folder.
Parameters:
- source_object (object): The source object containing related objects to duplicate.
- duplicate_object (object): The object where duplicated objects will be linked.
- target_folder (object): The folder where duplicated objects will be stored.
- field_name (str): The field name representing the related objects in the source object.
- model_class (type): The model class of the related objects.
- target_folder (Folder): The folder where duplicated objects will be stored.
- field_name (str): The field name representing the related objects in the source
"""

def process_related_object(
Expand Down Expand Up @@ -1248,6 +1246,8 @@ def duplicate_and_link_object(new_obj, duplicate_object, target_folder, field_na
new_obj.save()
link_existing_object(duplicate_object, new_obj, field_name)

model_class = getattr(type(source_object), field_name).field.related_model

# Get parent and sub-folders of the target folder
target_parent_folders = target_folder.get_parent_folders()
sub_folders = target_folder.sub_folders()
Expand Down
3 changes: 0 additions & 3 deletions backend/core/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -641,21 +641,18 @@ def duplicate(self, request, pk):
duplicate_scenario,
duplicate_risk_assessment.project.folder,
"applied_controls",
AppliedControl,
)
duplicate_related_objects(
scenario,
duplicate_scenario,
duplicate_risk_assessment.project.folder,
"threats",
Threat,
)
duplicate_related_objects(
scenario,
duplicate_scenario,
duplicate_risk_assessment.project.folder,
"assets",
Asset,
)

if (
Expand Down

0 comments on commit 4ceed7c

Please sign in to comment.