Browse Source

Add 'copy' to Actions

Guénaël Muller 6 years ago
parent
commit
20af75a898
2 changed files with 19 additions and 5 deletions
  1. 6 2
      tracim/tracim/lib/content.py
  2. 13 3
      tracim/tracim/model/data.py

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

906
         content.parent = parent
906
         content.parent = parent
907
         content.workspace = workspace
907
         content.workspace = workspace
908
         content.label = label
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
         DBSession.add(content)
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
     def move_recursively(self, item: Content,
917
     def move_recursively(self, item: Content,
914
                          new_parent: Content, new_workspace: Workspace):
918
                          new_parent: Content, new_workspace: Workspace):

+ 13 - 3
tracim/tracim/model/data.py View File

204
     - closed-deprecated
204
     - closed-deprecated
205
     """
205
     """
206
 
206
 
207
+    COPY = 'copy'
207
     ARCHIVING = 'archiving'
208
     ARCHIVING = 'archiving'
208
     COMMENT = 'content-comment'
209
     COMMENT = 'content-comment'
209
     CREATION = 'creation'
210
     CREATION = 'creation'
225
         'status-update': 'fa-random',
226
         'status-update': 'fa-random',
226
         'unarchiving': 'fa-file-archive-o',
227
         'unarchiving': 'fa-file-archive-o',
227
         'undeletion': 'fa-trash-o',
228
         'undeletion': 'fa-trash-o',
228
-        'move': 'fa-arrows'
229
+        'move': 'fa-arrows',
230
+        'copy': 'fa-files-o',
229
     }
231
     }
230
 
232
 
231
     _LABELS = {
233
     _LABELS = {
238
         'status-update': l_('New status'),
240
         'status-update': l_('New status'),
239
         'unarchiving': l_('Item unarchived'),
241
         'unarchiving': l_('Item unarchived'),
240
         'undeletion': l_('Item undeleted'),
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
     def __init__(self, id):
247
     def __init__(self, id):
259
                 cls.STATUS_UPDATE,
262
                 cls.STATUS_UPDATE,
260
                 cls.UNARCHIVING,
263
                 cls.UNARCHIVING,
261
                 cls.UNDELETION,
264
                 cls.UNDELETION,
262
-                cls.MOVE]
265
+                cls.MOVE,
266
+                cls.COPY,
267
+                ]
263
 
268
 
264
 
269
 
265
 class ContentStatus(object):
270
 class ContentStatus(object):
514
                 return False
519
                 return False
515
             return True
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
         raise NotImplementedError
527
         raise NotImplementedError
518
 
528
 
519
     @classmethod
529
     @classmethod