|
@@ -867,6 +867,15 @@ class ContentApi(object):
|
867
|
867
|
new_label: str=None,
|
868
|
868
|
do_notify: bool=True,
|
869
|
869
|
) -> Content:
|
|
870
|
+ """
|
|
871
|
+ Copy nearly all content, revision included. Children not included, see
|
|
872
|
+ "copy_children" for this.
|
|
873
|
+ :param item: Item to copy
|
|
874
|
+ :param new_parent: new parent of the new copied item
|
|
875
|
+ :param new_label: new label of the new copied item
|
|
876
|
+ :param do_notify: notify copy or not
|
|
877
|
+ :return: Newly copied item
|
|
878
|
+ """
|
870
|
879
|
if (not new_parent and not new_label) or (new_parent == item.parent and new_label == item.label): # nopep8
|
871
|
880
|
# TODO - G.M - 08-03-2018 - Use something else than value error
|
872
|
881
|
raise ValueError("You can't copy file into itself")
|
|
@@ -905,13 +914,13 @@ class ContentApi(object):
|
905
|
914
|
content.revision_type = ActionDescription.COPY
|
906
|
915
|
content.properties['origin'] = {
|
907
|
916
|
'content': item.id,
|
908
|
|
- 'revision' : item.last_revision.revision_id,
|
|
917
|
+ 'revision': item.last_revision.revision_id,
|
909
|
918
|
}
|
910
|
919
|
DBSession.add(content)
|
911
|
920
|
self.save(content, ActionDescription.COPY, do_notify=do_notify)
|
912
|
921
|
return content
|
913
|
922
|
|
914
|
|
- def copy_children(self, origin_content:Content, new_content: Content):
|
|
923
|
+ def copy_children(self, origin_content: Content, new_content: Content):
|
915
|
924
|
for child in origin_content.children:
|
916
|
925
|
self.copy(child, new_content)
|
917
|
926
|
|