Skip to content

Commit f3c1182

Browse files
committed
fixup! 🐛(backend) duplicate sub docs as root for reader user
1 parent 9b7d7f6 commit f3c1182

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

src/backend/core/api/viewsets.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -966,15 +966,13 @@ def duplicate(self, request, *args, **kwargs):
966966
attachments = list(
967967
extracted_attachments & set(document_to_duplicate.attachments)
968968
)
969-
if (
970-
not document_to_duplicate.is_root()
971-
and user_role == models.RoleChoices.READER
972-
):
969+
title = capfirst(_("copy of {title}").format(title=document_to_duplicate.title))
970+
if not document_to_duplicate.is_root() and choices.RoleChoices.get_priority(
971+
user_role
972+
) < choices.RoleChoices.get_priority(models.RoleChoices.EDITOR):
973973
duplicated_document = models.Document.add_root(
974974
creator=self.request.user,
975-
title=capfirst(
976-
_("copy of {title}").format(title=document_to_duplicate.title)
977-
),
975+
title=title,
978976
content=base64_yjs_content,
979977
attachments=attachments,
980978
duplicated_from=document_to_duplicate,
@@ -991,9 +989,7 @@ def duplicate(self, request, *args, **kwargs):
991989

992990
duplicated_document = document_to_duplicate.add_sibling(
993991
"right",
994-
title=capfirst(
995-
_("copy of {title}").format(title=document_to_duplicate.title)
996-
),
992+
title=title,
997993
content=base64_yjs_content,
998994
attachments=attachments,
999995
duplicated_from=document_to_duplicate,

0 commit comments

Comments
 (0)