Guénaël Muller před 6 roky
rodič
revize
75aeb8e865
1 změnil soubory, kde provedl 4 přidání a 12 odebrání
  1. 4 12
      tracim/tracim/lib/content.py

+ 4 - 12
tracim/tracim/lib/content.py Zobrazit soubor

@@ -865,6 +865,7 @@ class ContentApi(object):
865 865
         item: Content,
866 866
         new_parent: Content=None,
867 867
         new_label: str=None,
868
+        do_save: bool=True,
868 869
         do_notify: bool=True,
869 870
     ) -> Content:
870 871
         """
@@ -891,20 +892,11 @@ class ContentApi(object):
891 892
         else:
892 893
             label = item.label
893 894
 
894
-        # INFO - G.M - 15-03-2018 - Copy content with first_revision
895
-        # to have consistent content
896 895
         content = Content()
897
-        cpy_rev = ContentRevisionRO.copy(item.first_revision, parent)
898
-        content.revisions.append(cpy_rev)
899
-        DBSession.add(content)
900
-
901
-        # INFO - G.M - 15-03-2018 - Add all older revision (history)
896
+        # INFO - G.M - 15-03-2018 - Add all revisions (history)
902 897
         for rev in item.revisions:
903
-            if rev == item.first_revision:
904
-                continue
905 898
             cpy_rev = ContentRevisionRO.copy(rev, parent)
906 899
             content.revisions.append(cpy_rev)
907
-            DBSession.add(content)
908 900
 
909 901
         # INFO - GM - 15-03-2018 - add "copy" revision
910 902
         content.new_revision()
@@ -916,8 +908,8 @@ class ContentApi(object):
916 908
             'content': item.id,
917 909
             'revision': item.last_revision.revision_id,
918 910
         }
919
-        DBSession.add(content)
920
-        self.save(content, ActionDescription.COPY, do_notify=do_notify)
911
+        if do_save:
912
+            self.save(content, ActionDescription.COPY, do_notify=do_notify)
921 913
         return content
922 914
 
923 915
     def copy_children(self, origin_content: Content, new_content: Content):