Sfoglia il codice sorgente

refactor copy into model

Guénaël Muller 6 anni fa
parent
commit
29f7860358
2 ha cambiato i file con 8 aggiunte e 6 eliminazioni
  1. 1 6
      tracim/tracim/lib/content.py
  2. 7 0
      tracim/tracim/model/data.py

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

@@ -892,12 +892,7 @@ class ContentApi(object):
892 892
         else:
893 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 896
         # INFO - GM - 15-03-2018 - add "copy" revision
902 897
         content.new_revision()
903 898
         content.parent = parent

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

@@ -1293,6 +1293,13 @@ class Content(DeclarativeBase):
1293 1293
         cid = content.content_id
1294 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 1304
 class RevisionReadStatus(DeclarativeBase):
1298 1305