Guénaël Muller 6 лет назад
Родитель
Сommit
20af75a898
2 измененных файлов: 19 добавлений и 5 удалений
  1. 6 2
      tracim/tracim/lib/content.py
  2. 13 3
      tracim/tracim/model/data.py

+ 6 - 2
tracim/tracim/lib/content.py Просмотреть файл

@@ -906,9 +906,13 @@ class ContentApi(object):
906 906
         content.parent = parent
907 907
         content.workspace = workspace
908 908
         content.label = label
909
-        content.revision_type = ActionDescription.MOVE
909
+        content.revision_type = ActionDescription.COPY
910
+        content.properties['origin'] = {
911
+            'content': item.id,
912
+            'revision' : item.last_revision.revision_id,
913
+        }
910 914
         DBSession.add(content)
911
-        self.save(content, ActionDescription.MOVE, do_notify=do_notify)
915
+        self.save(content, ActionDescription.COPY, do_notify=do_notify)
912 916
 
913 917
     def move_recursively(self, item: Content,
914 918
                          new_parent: Content, new_workspace: Workspace):

+ 13 - 3
tracim/tracim/model/data.py Просмотреть файл

@@ -204,6 +204,7 @@ class ActionDescription(object):
204 204
     - closed-deprecated
205 205
     """
206 206
 
207
+    COPY = 'copy'
207 208
     ARCHIVING = 'archiving'
208 209
     COMMENT = 'content-comment'
209 210
     CREATION = 'creation'
@@ -225,7 +226,8 @@ class ActionDescription(object):
225 226
         'status-update': 'fa-random',
226 227
         'unarchiving': 'fa-file-archive-o',
227 228
         'undeletion': 'fa-trash-o',
228
-        'move': 'fa-arrows'
229
+        'move': 'fa-arrows',
230
+        'copy': 'fa-files-o',
229 231
     }
230 232
 
231 233
     _LABELS = {
@@ -238,7 +240,8 @@ class ActionDescription(object):
238 240
         'status-update': l_('New status'),
239 241
         'unarchiving': l_('Item unarchived'),
240 242
         'undeletion': l_('Item undeleted'),
241
-        'move': l_('Item moved')
243
+        'move': l_('Item moved'),
244
+        'copy': l_('Item copied'),
242 245
     }
243 246
 
244 247
     def __init__(self, id):
@@ -259,7 +262,9 @@ class ActionDescription(object):
259 262
                 cls.STATUS_UPDATE,
260 263
                 cls.UNARCHIVING,
261 264
                 cls.UNDELETION,
262
-                cls.MOVE]
265
+                cls.MOVE,
266
+                cls.COPY,
267
+                ]
263 268
 
264 269
 
265 270
 class ContentStatus(object):
@@ -514,6 +519,11 @@ class ContentChecker(object):
514 519
                 return False
515 520
             return True
516 521
 
522
+        # TODO - G.M - 15-03-2018 - Choose only correct Content-type for origin
523
+        # Only content who can be copied need this
524
+        if item.type == ContentType.Any:
525
+            if 'origin' in properties.keys():
526
+                return True
517 527
         raise NotImplementedError
518 528
 
519 529
     @classmethod