|
|
|
|
867
|
new_label: str=None,
|
867
|
new_label: str=None,
|
868
|
do_notify: bool=True,
|
868
|
do_notify: bool=True,
|
869
|
) -> Content:
|
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
|
if (not new_parent and not new_label) or (new_parent == item.parent and new_label == item.label): # nopep8
|
879
|
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
|
880
|
# TODO - G.M - 08-03-2018 - Use something else than value error
|
872
|
raise ValueError("You can't copy file into itself")
|
881
|
raise ValueError("You can't copy file into itself")
|
|
|
|
|
905
|
content.revision_type = ActionDescription.COPY
|
914
|
content.revision_type = ActionDescription.COPY
|
906
|
content.properties['origin'] = {
|
915
|
content.properties['origin'] = {
|
907
|
'content': item.id,
|
916
|
'content': item.id,
|
908
|
- 'revision' : item.last_revision.revision_id,
|
|
|
|
|
917
|
+ 'revision': item.last_revision.revision_id,
|
909
|
}
|
918
|
}
|
910
|
DBSession.add(content)
|
919
|
DBSession.add(content)
|
911
|
self.save(content, ActionDescription.COPY, do_notify=do_notify)
|
920
|
self.save(content, ActionDescription.COPY, do_notify=do_notify)
|
912
|
return content
|
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
|
for child in origin_content.children:
|
924
|
for child in origin_content.children:
|
916
|
self.copy(child, new_content)
|
925
|
self.copy(child, new_content)
|
917
|
|
926
|
|