|
@@ -865,7 +865,6 @@ class ContentApi(object):
|
865
|
865
|
item: Content,
|
866
|
866
|
new_parent: Content=None,
|
867
|
867
|
new_label: str=None,
|
868
|
|
- do_save: bool=True,
|
869
|
868
|
do_notify: bool=True,
|
870
|
869
|
) -> None:
|
871
|
870
|
if (not new_parent and not new_label) or (new_parent == item.parent and new_label == item.label): # nopep8
|
|
@@ -883,31 +882,33 @@ class ContentApi(object):
|
883
|
882
|
else:
|
884
|
883
|
label = item.label
|
885
|
884
|
|
886
|
|
- with DBSession.no_autoflush:
|
|
885
|
+ # INFO - G.M - 15-03-2018 - Copy content with first_revision
|
|
886
|
+ # to have consistent content
|
|
887
|
+ content = Content()
|
|
888
|
+ cpy_rev = ContentRevisionRO.copy(item.first_revision, parent)
|
|
889
|
+ content.revisions.append(cpy_rev)
|
|
890
|
+ DBSession.add(content)
|
|
891
|
+
|
|
892
|
+ # INFO - G.M - 15-03-2018 - Add all older revision (history)
|
|
893
|
+ for rev in item.revisions:
|
|
894
|
+ if rev == item.first_revision:
|
|
895
|
+ continue
|
|
896
|
+ cpy_rev = ContentRevisionRO.copy(rev, parent)
|
|
897
|
+ content.revisions.append(cpy_rev)
|
|
898
|
+ DBSession.add(content)
|
887
|
899
|
|
888
|
|
- file = self.create(
|
889
|
|
- content_type=item.type,
|
890
|
|
- workspace=workspace,
|
891
|
|
- parent=parent,
|
892
|
|
- label=label,
|
893
|
|
- do_save=False,
|
894
|
|
- )
|
895
|
|
- file.description = item.description
|
896
|
|
- if item.depot_file:
|
897
|
|
- self.update_file_data(
|
898
|
|
- file,
|
899
|
|
- item.file_name,
|
900
|
|
- item.file_mimetype,
|
901
|
|
- item.depot_file.file
|
902
|
|
- )
|
903
|
|
- for child in item.get_comments():
|
904
|
|
- self.copy(child,
|
905
|
|
- new_parent=file,
|
906
|
|
- do_notify=False,
|
907
|
|
- do_save=False,
|
908
|
|
- )
|
909
|
|
- if do_save:
|
910
|
|
- self.save(file, ActionDescription.CREATION, do_notify=do_notify)
|
|
900
|
+ # INFO - G.M - 15-03-2018 - copy childrens (comments and others things)
|
|
901
|
+ for child in item.children:
|
|
902
|
+ self.copy(child, content)
|
|
903
|
+
|
|
904
|
+ # INFO - GM - 15-03-2018 - add "copy" revision
|
|
905
|
+ content.new_revision()
|
|
906
|
+ content.parent = parent
|
|
907
|
+ content.workspace = workspace
|
|
908
|
+ content.label = label
|
|
909
|
+ content.revision_type = ActionDescription.MOVE
|
|
910
|
+ DBSession.add(content)
|
|
911
|
+ self.save(content, ActionDescription.MOVE, do_notify=do_notify)
|
911
|
912
|
|
912
|
913
|
def move_recursively(self, item: Content,
|
913
|
914
|
new_parent: Content, new_workspace: Workspace):
|