Browse Source

Add is_deleted field in workspace digest schema

Guénaël Muller 6 years ago
parent
commit
489e7f93dd

+ 7 - 0
backend/tracim_backend/models/context_models.py View File

@@ -455,6 +455,13 @@ class WorkspaceInContext(object):
455 455
         return slugify(self.workspace.label)
456 456
 
457 457
     @property
458
+    def is_deleted(self) -> bool:
459
+        """
460
+        Is the workspace deleted ?
461
+        """
462
+        return self.workspace.is_deleted
463
+
464
+    @property
458 465
     def sidebar_entries(self) -> typing.List[WorkspaceMenuEntry]:
459 466
         """
460 467
         get sidebar entries, those depends on activated apps.

+ 1 - 1
backend/tracim_backend/tests/functional/test_user.py View File

@@ -2382,6 +2382,7 @@ class TestUserWorkspaceEndpoint(FunctionalTest):
2382 2382
         assert workspace['workspace_id'] == 1
2383 2383
         assert workspace['label'] == 'Business'
2384 2384
         assert workspace['slug'] == 'business'
2385
+        assert workspace['is_deleted'] is False
2385 2386
         assert len(workspace['sidebar_entries']) == 5
2386 2387
 
2387 2388
         # TODO - G.M - 2018-08-02 - Better test for sidebar entry, make it
@@ -2421,7 +2422,6 @@ class TestUserWorkspaceEndpoint(FunctionalTest):
2421 2422
         assert sidebar_entry['hexcolor'] == "#ad4cf9"
2422 2423
         assert sidebar_entry['fa_icon'] == "comments-o"
2423 2424
 
2424
-
2425 2425
     def test_api__get_user_workspaces__err_403__unallowed_user(self):
2426 2426
         """
2427 2427
         Check obtain all workspaces reachables for one user

+ 4 - 0
backend/tracim_backend/tests/functional/test_workspaces.py View File

@@ -41,6 +41,7 @@ class TestWorkspaceEndpoint(FunctionalTest):
41 41
         assert workspace['slug'] == 'business'
42 42
         assert workspace['label'] == 'Business'
43 43
         assert workspace['description'] == 'All importants documents'
44
+        assert workspace['is_deleted'] is False
44 45
         assert len(workspace['sidebar_entries']) == 5
45 46
 
46 47
         # TODO - G.M - 2018-08-02 - Better test for sidebar entry, make it
@@ -106,6 +107,7 @@ class TestWorkspaceEndpoint(FunctionalTest):
106 107
         assert workspace['slug'] == 'business'
107 108
         assert workspace['label'] == 'Business'
108 109
         assert workspace['description'] == 'All importants documents'
110
+        assert workspace['is_deleted'] is False
109 111
         assert len(workspace['sidebar_entries']) == 5
110 112
 
111 113
         # modify workspace
@@ -120,6 +122,7 @@ class TestWorkspaceEndpoint(FunctionalTest):
120 122
         assert workspace['slug'] == 'superworkspace'
121 123
         assert workspace['label'] == 'superworkspace'
122 124
         assert workspace['description'] == 'mysuperdescription'
125
+        assert workspace['is_deleted'] is False
123 126
         assert len(workspace['sidebar_entries']) == 5
124 127
 
125 128
         # after
@@ -133,6 +136,7 @@ class TestWorkspaceEndpoint(FunctionalTest):
133 136
         assert workspace['slug'] == 'superworkspace'
134 137
         assert workspace['label'] == 'superworkspace'
135 138
         assert workspace['description'] == 'mysuperdescription'
139
+        assert workspace['is_deleted'] is False
136 140
         assert len(workspace['sidebar_entries']) == 5
137 141
 
138 142
     def test_api__update_workspace__err_400__empty_label(self) -> None:

+ 1 - 0
backend/tracim_backend/views/core_api/schemas.py View File

@@ -509,6 +509,7 @@ class WorkspaceDigestSchema(marshmallow.Schema):
509 509
         WorkspaceMenuEntrySchema,
510 510
         many=True,
511 511
     )
512
+    is_deleted = marshmallow.fields.Bool(example=False, default=False)
512 513
 
513 514
     class Meta:
514 515
         description = 'Digest of workspace informations'