Browse Source

rename status_slug and role_slug

Guénaël Muller 6 years ago
parent
commit
319e26f2d1

+ 6 - 2
tracim/models/context_models.py View File

@@ -226,12 +226,16 @@ class UserRoleWorkspaceInContext(object):
226 226
         return self.user_role.role
227 227
 
228 228
     @property
229
+    def role(self) -> str:
230
+        return self.role_slug
231
+
232
+    @property
229 233
     def role_slug(self) -> str:
230 234
         """
231 235
         simple name of the role of the user.
232 236
         can be anything from UserRoleInWorkspace SLUG, like
233 237
         'not_applicable', 'reader',
234
-        'contributor', 'content_manager', 'workspace_manager'
238
+        'contributor', 'content-manager', 'workspace-manager'
235 239
         :return: user workspace role as slug.
236 240
         """
237 241
         return UserRoleInWorkspace.SLUG[self.user_role.role]
@@ -298,7 +302,7 @@ class ContentInContext(object):
298 302
         return [type.slug for type in self.content.get_allowed_content_types()]
299 303
 
300 304
     @property
301
-    def status_slug(self) -> str:
305
+    def status(self) -> str:
302 306
         return self.content.status
303 307
 
304 308
     @property

+ 17 - 17
tracim/tests/functional/test_workspaces.py View File

@@ -155,7 +155,7 @@ class TestWorkspaceMembersEndpoint(FunctionalTest):
155 155
         res = self.testapp.get('/api/v2/workspaces/1/members', status=200).json_body   # nopep8
156 156
         assert len(res) == 1
157 157
         user_role = res[0]
158
-        assert user_role['role_slug'] == 'workspace-manager'
158
+        assert user_role['role'] == 'workspace-manager'
159 159
         assert user_role['user_id'] == 1
160 160
         assert user_role['workspace_id'] == 1
161 161
         assert user_role['user']['display_name'] == 'Global manager'
@@ -246,7 +246,7 @@ class TestWorkspaceContents(FunctionalTest):
246 246
         assert content['parent_id'] is None
247 247
         assert content['show_in_ui'] is True
248 248
         assert content['slug'] == 'tools'
249
-        assert content['status_slug'] == 'open'
249
+        assert content['status'] == 'open'
250 250
         assert set(content['sub_content_types']) == {'thread', 'page', 'folder', 'file'}  # nopep8
251 251
         assert content['workspace_id'] == 1
252 252
         content = res[1]
@@ -257,7 +257,7 @@ class TestWorkspaceContents(FunctionalTest):
257 257
         assert content['parent_id'] is None
258 258
         assert content['show_in_ui'] is True
259 259
         assert content['slug'] == 'menus'
260
-        assert content['status_slug'] == 'open'
260
+        assert content['status'] == 'open'
261 261
         assert set(content['sub_content_types']) == {'thread', 'page', 'folder', 'file'}  # nopep8
262 262
         assert content['workspace_id'] == 1
263 263
         content = res[2]
@@ -268,7 +268,7 @@ class TestWorkspaceContents(FunctionalTest):
268 268
         assert content['parent_id'] == 2
269 269
         assert content['show_in_ui'] is True
270 270
         assert content['slug'] == 'current-menu'
271
-        assert content['status_slug'] == 'open'
271
+        assert content['status'] == 'open'
272 272
         assert set(content['sub_content_types']) == {'thread', 'page', 'folder', 'file'}  # nopep8
273 273
         assert content['workspace_id'] == 1
274 274
 
@@ -307,7 +307,7 @@ class TestWorkspaceContents(FunctionalTest):
307 307
         assert content['parent_id'] is None
308 308
         assert content['show_in_ui'] is True
309 309
         assert content['slug'] == 'new-fruit-salad'
310
-        assert content['status_slug'] == 'open'
310
+        assert content['status'] == 'open'
311 311
         assert set(content['sub_content_types']) == {'thread', 'page', 'folder', 'file'}  # nopep8
312 312
         assert content['workspace_id'] == 3
313 313
 
@@ -320,7 +320,7 @@ class TestWorkspaceContents(FunctionalTest):
320 320
         assert content['parent_id'] is None
321 321
         assert content['show_in_ui'] is True
322 322
         assert content['slug'].startswith('fruit-salad')
323
-        assert content['status_slug'] == 'open'
323
+        assert content['status'] == 'open'
324 324
         assert set(content['sub_content_types']) == {'thread', 'page', 'folder', 'file'}  # nopep8
325 325
         assert content['workspace_id'] == 3
326 326
 
@@ -333,7 +333,7 @@ class TestWorkspaceContents(FunctionalTest):
333 333
         assert content['parent_id'] is None
334 334
         assert content['show_in_ui'] is True
335 335
         assert content['slug'].startswith('bad-fruit-salad')
336
-        assert content['status_slug'] == 'open'
336
+        assert content['status'] == 'open'
337 337
         assert set(content['sub_content_types']) == {'thread', 'page', 'folder', 'file'}  # nopep8
338 338
         assert content['workspace_id'] == 3
339 339
 
@@ -370,7 +370,7 @@ class TestWorkspaceContents(FunctionalTest):
370 370
         assert content['parent_id'] is None
371 371
         assert content['show_in_ui'] is True
372 372
         assert content['slug'] == 'new-fruit-salad'
373
-        assert content['status_slug'] == 'open'
373
+        assert content['status'] == 'open'
374 374
         assert set(content['sub_content_types']) == {'thread', 'page', 'folder', 'file'}  # nopep8
375 375
         assert content['workspace_id'] == 3
376 376
 
@@ -406,7 +406,7 @@ class TestWorkspaceContents(FunctionalTest):
406 406
         assert content['parent_id'] is None
407 407
         assert content['show_in_ui'] is True
408 408
         assert content['slug'].startswith('fruit-salad')
409
-        assert content['status_slug'] == 'open'
409
+        assert content['status'] == 'open'
410 410
         assert set(content['sub_content_types']) == {'thread', 'page', 'folder', 'file'}  # nopep8
411 411
         assert content['workspace_id'] == 3
412 412
 
@@ -444,7 +444,7 @@ class TestWorkspaceContents(FunctionalTest):
444 444
         assert content['parent_id'] is None
445 445
         assert content['show_in_ui'] is True
446 446
         assert content['slug'].startswith('bad-fruit-salad')
447
-        assert content['status_slug'] == 'open'
447
+        assert content['status'] == 'open'
448 448
         assert set(content['sub_content_types']) == {'thread', 'page', 'folder', 'file'}  # nopep8
449 449
         assert content['workspace_id'] == 3
450 450
 
@@ -508,7 +508,7 @@ class TestWorkspaceContents(FunctionalTest):
508 508
         assert content['parent_id'] == 10
509 509
         assert content['show_in_ui'] is True
510 510
         assert content['slug'] == 'new-fruit-salad'
511
-        assert content['status_slug'] == 'open'
511
+        assert content['status'] == 'open'
512 512
         assert set(content['sub_content_types']) == {'thread', 'page', 'folder', 'file'}  # nopep8
513 513
         assert content['workspace_id'] == 2
514 514
 
@@ -521,7 +521,7 @@ class TestWorkspaceContents(FunctionalTest):
521 521
         assert content['parent_id'] == 10
522 522
         assert content['show_in_ui'] is True
523 523
         assert content['slug'].startswith('fruit-salad')
524
-        assert content['status_slug'] == 'open'
524
+        assert content['status'] == 'open'
525 525
         assert set(content['sub_content_types']) == {'thread', 'page', 'folder', 'file'}  # nopep8
526 526
         assert content['workspace_id'] == 2
527 527
 
@@ -534,7 +534,7 @@ class TestWorkspaceContents(FunctionalTest):
534 534
         assert content['parent_id'] == 10
535 535
         assert content['show_in_ui'] is True
536 536
         assert content['slug'].startswith('bad-fruit-salad')
537
-        assert content['status_slug'] == 'open'
537
+        assert content['status'] == 'open'
538 538
         assert set(content['sub_content_types']) == {'thread', 'page', 'folder', 'file'}  # nopep8
539 539
         assert content['workspace_id'] == 2
540 540
 
@@ -570,7 +570,7 @@ class TestWorkspaceContents(FunctionalTest):
570 570
         assert content['parent_id'] == 10
571 571
         assert content['show_in_ui'] is True
572 572
         assert content['slug'] == 'new-fruit-salad'
573
-        assert content['status_slug'] == 'open'
573
+        assert content['status'] == 'open'
574 574
         assert set(content['sub_content_types']) == {'thread', 'page', 'folder', 'file'}  # nopep8
575 575
         assert content['workspace_id'] == 2
576 576
 
@@ -606,7 +606,7 @@ class TestWorkspaceContents(FunctionalTest):
606 606
         assert content['parent_id'] == 10
607 607
         assert content['show_in_ui'] is True
608 608
         assert content['slug'].startswith('fruit-salad')
609
-        assert content['status_slug'] == 'open'
609
+        assert content['status'] == 'open'
610 610
         assert set(content['sub_content_types']) == {'thread', 'page', 'folder', 'file'}  # nopep8
611 611
         assert content['workspace_id'] == 2
612 612
 
@@ -643,7 +643,7 @@ class TestWorkspaceContents(FunctionalTest):
643 643
         assert content['parent_id'] == 10
644 644
         assert content['show_in_ui'] is True
645 645
         assert content['slug'].startswith('bad-fruit-salad')
646
-        assert content['status_slug'] == 'open'
646
+        assert content['status'] == 'open'
647 647
         assert set(content['sub_content_types']) == {'thread', 'page', 'folder', 'file'}  # nopep8
648 648
         assert content['workspace_id'] == 2
649 649
 
@@ -750,7 +750,7 @@ class TestWorkspaceContents(FunctionalTest):
750 750
         )
751 751
         assert res
752 752
         assert res.json_body
753
-        assert res.json_body['status_slug'] == 'open'
753
+        assert res.json_body['status'] == 'open'
754 754
         assert res.json_body['id']
755 755
         assert res.json_body['content_type'] == 'markdownpage'
756 756
         assert res.json_body['is_archived'] is False

+ 2 - 2
tracim/views/core_api/schemas.py View File

@@ -207,7 +207,7 @@ class WorkspaceSchema(WorkspaceDigestSchema):
207 207
 
208 208
 
209 209
 class WorkspaceMemberSchema(marshmallow.Schema):
210
-    role_slug = marshmallow.fields.String(
210
+    role = marshmallow.fields.String(
211 211
         example='contributor',
212 212
         validate=OneOf(UserRoleInWorkspace.get_all_role_slug())
213 213
     )
@@ -343,7 +343,7 @@ class ContentDigestSchema(marshmallow.Schema):
343 343
                     'This field is required for folder contents, '
344 344
                     'set it to empty list in other cases'
345 345
     )
346
-    status_slug = marshmallow.fields.Str(
346
+    status = marshmallow.fields.Str(
347 347
         example='closed-deprecated',
348 348
         validate=OneOf([status.slug for status in CONTENT_DEFAULT_STATUS]),
349 349
         description='this slug is found in content_type available statuses',