Browse Source

refactor copy into model

Guénaël Muller 6 years ago
parent
commit
29f7860358
2 changed files with 8 additions and 6 deletions
  1. 1 6
      tracim/tracim/lib/content.py
  2. 7 0
      tracim/tracim/model/data.py

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

892
         else:
892
         else:
893
             label = item.label
893
             label = item.label
894
 
894
 
895
-        content = Content()
896
-        # INFO - G.M - 15-03-2018 - Add all revisions (history)
897
-        for rev in item.revisions:
898
-            cpy_rev = ContentRevisionRO.copy(rev, parent)
899
-            content.revisions.append(cpy_rev)
900
-
895
+        content = item.copy(parent)
901
         # INFO - GM - 15-03-2018 - add "copy" revision
896
         # INFO - GM - 15-03-2018 - add "copy" revision
902
         content.new_revision()
897
         content.new_revision()
903
         content.parent = parent
898
         content.parent = parent

+ 7 - 0
tracim/tracim/model/data.py View File

1293
         cid = content.content_id
1293
         cid = content.content_id
1294
         return url_template.format(wid=wid, fid=fid, ctype=ctype, cid=cid)
1294
         return url_template.format(wid=wid, fid=fid, ctype=ctype, cid=cid)
1295
 
1295
 
1296
+    def copy(self, parent):
1297
+        cpy_content = Content()
1298
+        for rev in self.revisions:
1299
+            cpy_rev = ContentRevisionRO.copy(rev, parent)
1300
+            cpy_content.revisions.append(cpy_rev)
1301
+        return cpy_content
1302
+
1296
 
1303
 
1297
 class RevisionReadStatus(DeclarativeBase):
1304
 class RevisionReadStatus(DeclarativeBase):
1298
 
1305