Parcourir la source

add revision_type to revisions in endpoints

Guénaël Muller il y a 6 ans
Parent
révision
5761c84cce

+ 4 - 0
tracim/models/context_models.py Voir le fichier

456
         return self.revision.label
456
         return self.revision.label
457
 
457
 
458
     @property
458
     @property
459
+    def revision_type(self) -> str:
460
+        return self.revision.revision_type
461
+
462
+    @property
459
     def content_type(self) -> str:
463
     def content_type(self) -> str:
460
         content_type = ContentType(self.revision.type)
464
         content_type = ContentType(self.revision.type)
461
         if content_type:
465
         if content_type:

+ 5 - 0
tracim/tests/functional/test_contents.py Voir le fichier

314
         assert revision['status'] == 'open'
314
         assert revision['status'] == 'open'
315
         assert revision['workspace_id'] == 2
315
         assert revision['workspace_id'] == 2
316
         assert revision['revision_id'] == 6
316
         assert revision['revision_id'] == 6
317
+        assert revision['revision_type'] == 'creation'
317
         assert revision['sub_content_types']
318
         assert revision['sub_content_types']
318
         # TODO - G.M - 2018-06-173 - Test with real comments
319
         # TODO - G.M - 2018-06-173 - Test with real comments
319
         assert revision['comment_ids'] == []
320
         assert revision['comment_ids'] == []
335
         assert revision['status'] == 'open'
336
         assert revision['status'] == 'open'
336
         assert revision['workspace_id'] == 2
337
         assert revision['workspace_id'] == 2
337
         assert revision['revision_id'] == 7
338
         assert revision['revision_id'] == 7
339
+        assert revision['revision_type'] == 'edition'
338
         assert revision['sub_content_types']
340
         assert revision['sub_content_types']
339
         # TODO - G.M - 2018-06-173 - Test with real comments
341
         # TODO - G.M - 2018-06-173 - Test with real comments
340
         assert revision['comment_ids'] == []
342
         assert revision['comment_ids'] == []
356
         assert revision['status'] == 'open'
358
         assert revision['status'] == 'open'
357
         assert revision['workspace_id'] == 2
359
         assert revision['workspace_id'] == 2
358
         assert revision['revision_id'] == 27
360
         assert revision['revision_id'] == 27
361
+        assert revision['revision_type'] == 'edition'
359
         assert revision['sub_content_types']
362
         assert revision['sub_content_types']
360
         # TODO - G.M - 2018-06-173 - Test with real comments
363
         # TODO - G.M - 2018-06-173 - Test with real comments
361
         assert revision['comment_ids'] == []
364
         assert revision['comment_ids'] == []
697
         assert revision['workspace_id'] == 2
700
         assert revision['workspace_id'] == 2
698
         assert revision['revision_id'] == 8
701
         assert revision['revision_id'] == 8
699
         assert revision['sub_content_types']
702
         assert revision['sub_content_types']
703
+        assert revision['revision_type'] == 'creation'
700
         assert revision['comment_ids'] == [18, 19, 20]
704
         assert revision['comment_ids'] == [18, 19, 20]
701
         # TODO - G.M - 2018-06-173 - check date format
705
         # TODO - G.M - 2018-06-173 - check date format
702
         assert revision['created']
706
         assert revision['created']
716
         assert revision['status'] == 'open'
720
         assert revision['status'] == 'open'
717
         assert revision['workspace_id'] == 2
721
         assert revision['workspace_id'] == 2
718
         assert revision['revision_id'] == 26
722
         assert revision['revision_id'] == 26
723
+        assert revision['revision_type'] == 'edition'
719
         assert revision['sub_content_types']
724
         assert revision['sub_content_types']
720
         assert revision['comment_ids'] == []
725
         assert revision['comment_ids'] == []
721
         # TODO - G.M - 2018-06-173 - check date format
726
         # TODO - G.M - 2018-06-173 - check date format

+ 5 - 1
tracim/views/core_api/schemas.py Voir le fichier

19
 from tracim.models.context_models import WorkspaceAndContentPath
19
 from tracim.models.context_models import WorkspaceAndContentPath
20
 from tracim.models.context_models import ContentFilter
20
 from tracim.models.context_models import ContentFilter
21
 from tracim.models.context_models import LoginCredentials
21
 from tracim.models.context_models import LoginCredentials
22
-from tracim.models.data import UserRoleInWorkspace
22
+from tracim.models.data import UserRoleInWorkspace, ActionDescription
23
 
23
 
24
 
24
 
25
 class UserDigestSchema(marshmallow.Schema):
25
 class UserDigestSchema(marshmallow.Schema):
468
         example=12,
468
         example=12,
469
         validate=Range(min=1, error="Value must be greater than 0"),
469
         validate=Range(min=1, error="Value must be greater than 0"),
470
     )
470
     )
471
+    revision_type = marshmallow.fields.String(
472
+        example=ActionDescription.CREATION,
473
+        validate=OneOf(ActionDescription.allowed_values()),
474
+    )
471
     created = marshmallow.fields.DateTime(
475
     created = marshmallow.fields.DateTime(
472
         format=DATETIME_FORMAT,
476
         format=DATETIME_FORMAT,
473
         description='Content creation date',
477
         description='Content creation date',