Browse Source

rename status_slug and role_slug

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

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

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

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

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

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

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