Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion dojo/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -803,7 +803,12 @@ def delete(self, *args, **kwargs):
def copy(self):
copy = copy_model_util(self)
# Add unique modifier to file name
copy.title = f"{self.title} - clone-{str(uuid4())[:8]}"
# Truncate title to ensure it doesn't exceed max_length (100) when appending suffix
# Suffix " - clone-{8 chars}" is 17 characters, so truncate to 83 chars
clone_suffix = f" - clone-{str(uuid4())[:8]}"
max_title_length = 100 - len(clone_suffix)
truncated_title = self.title[:max_title_length] if len(self.title) > max_title_length else self.title
copy.title = f"{truncated_title}{clone_suffix}"
# Create new unique file name
current_url = self.file.url
_, current_full_filename = current_url.rsplit("/", 1)
Expand Down