Browse Source

Fix copy chidren by abandon of recursive strategy

Guénaël Muller 6 years ago
parent
commit
583704950e
2 changed files with 8 additions and 8 deletions
  1. 6 6
      tracim/tracim/lib/content.py
  2. 2 2
      tracim/tracim/lib/webdav/sql_resources.py

+ 6 - 6
tracim/tracim/lib/content.py View File

866
         new_parent: Content=None,
866
         new_parent: Content=None,
867
         new_label: str=None,
867
         new_label: str=None,
868
         do_notify: bool=True,
868
         do_notify: bool=True,
869
-    ) -> None:
869
+    ) -> Content:
870
         if (not new_parent and not new_label) or (new_parent == item.parent and new_label == item.label):  # nopep8
870
         if (not new_parent and not new_label) or (new_parent == item.parent and new_label == item.label):  # nopep8
871
             # TODO - G.M - 08-03-2018 - Use something else than value error
871
             # TODO - G.M - 08-03-2018 - Use something else than value error
872
             raise ValueError("You can't copy file into itself")
872
             raise ValueError("You can't copy file into itself")
897
             content.revisions.append(cpy_rev)
897
             content.revisions.append(cpy_rev)
898
             DBSession.add(content)
898
             DBSession.add(content)
899
 
899
 
900
-        # TODO - G.M - 15-03-2018 - Child copy broken !
901
-        # INFO - G.M - 15-03-2018 - copy childrens (comments and others things)
902
-        # for child in item.children:
903
-        #    self.copy(child, content)
904
-
905
         # INFO - GM - 15-03-2018 - add "copy" revision
900
         # INFO - GM - 15-03-2018 - add "copy" revision
906
         content.new_revision()
901
         content.new_revision()
907
         content.parent = parent
902
         content.parent = parent
914
         }
909
         }
915
         DBSession.add(content)
910
         DBSession.add(content)
916
         self.save(content, ActionDescription.COPY, do_notify=do_notify)
911
         self.save(content, ActionDescription.COPY, do_notify=do_notify)
912
+        return content
913
+
914
+    def copy_children(self, origin_content:Content, new_content: Content):
915
+        for child in origin_content.children:
916
+            self.copy(child, new_content)
917
 
917
 
918
     def move_recursively(self, item: Content,
918
     def move_recursively(self, item: Content,
919
                          new_parent: Content, new_workspace: Workspace):
919
                          new_parent: Content, new_workspace: Workspace):

+ 2 - 2
tracim/tracim/lib/webdav/sql_resources.py View File

1039
         )
1039
         )
1040
         workspace = self.content.workspace
1040
         workspace = self.content.workspace
1041
         parent = self.content.parent
1041
         parent = self.content.parent
1042
-        self.content_api.copy(
1042
+        new_content = self.content_api.copy(
1043
             item=self.content,
1043
             item=self.content,
1044
             new_label=new_file_name,
1044
             new_label=new_file_name,
1045
             new_parent=destination_parent,
1045
             new_parent=destination_parent,
1046
         )
1046
         )
1047
-
1047
+        self.content_api.copy_children(self.content, new_content)
1048
         transaction.commit()
1048
         transaction.commit()
1049
 
1049
 
1050
     def supportRecursiveMove(self, destPath):
1050
     def supportRecursiveMove(self, destPath):