Skip to content

Commit

Permalink
feat: add duplication from sub folders
Browse files Browse the repository at this point in the history
  • Loading branch information
Mohamed-Hacene committed Oct 17, 2024
1 parent 0253f45 commit 1e88dbf
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions backend/core/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1193,6 +1193,7 @@ def duplicate_related_objects(

# Get parent folders of the target folder
target_parent_folders = target_folder.get_parent_folders()
sub_folders = target_folder.sub_folders()

# Fetch all related objects for the given field name
related_objects = getattr(object, field_name).all()
Expand All @@ -1210,6 +1211,10 @@ def duplicate_related_objects(
elif obj.folder in target_parent_folders and obj.is_published:
# If the object's folder is a parent of the targert folder and is published, add the object to the duplicate object
getattr(duplicate_object, field_name).add(obj)

elif obj.folder in sub_folders:
# If the object's folder is a subfolder of the target folder, add the object to the duplicate object
getattr(duplicate_object, field_name).add(obj)

else:
# If the object doesn't exist, duplicate the object
Expand Down

0 comments on commit 1e88dbf

Please sign in to comment.