Browse Source

add revision_type to revisions in endpoints

Guénaël Muller 5 years ago
parent
commit
5761c84cce

+ 4 - 0
tracim/models/context_models.py View File

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

+ 5 - 0
tracim/tests/functional/test_contents.py View File

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

+ 5 - 1
tracim/views/core_api/schemas.py View File

@@ -19,7 +19,7 @@ from tracim.models.context_models import MoveParams
19 19
 from tracim.models.context_models import WorkspaceAndContentPath
20 20
 from tracim.models.context_models import ContentFilter
21 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 25
 class UserDigestSchema(marshmallow.Schema):
@@ -468,6 +468,10 @@ class RevisionSchema(ContentDigestSchema):
468 468
         example=12,
469 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 475
     created = marshmallow.fields.DateTime(
472 476
         format=DATETIME_FORMAT,
473 477
         description='Content creation date',