Browse Source

Merge branch 'fix/592_fix_schema_and_http_code_in_endpoints' of github.com:tracim/tracim_backend into fix/596_move_endpoint_return_updated_content

Guénaël Muller 6 years ago
parent
commit
377c6ea386

+ 19 - 8
tracim/models/context_models.py View File

65
     def __init__(
65
     def __init__(
66
             self,
66
             self,
67
             label: str,
67
             label: str,
68
-            content_type_slug: str,
68
+            content_type: str,
69
     ):
69
     ):
70
         self.label = label
70
         self.label = label
71
-        self.content_type_slug = content_type_slug
71
+        self.content_type = content_type
72
 
72
 
73
 
73
 
74
 class UserInContext(object):
74
 class UserInContext(object):
92
         return self.user.user_id
92
         return self.user.user_id
93
 
93
 
94
     @property
94
     @property
95
+    def public_name(self) -> str:
96
+        return self.display_name
97
+
98
+    @property
95
     def display_name(self) -> str:
99
     def display_name(self) -> str:
96
         return self.user.display_name
100
         return self.user.display_name
97
 
101
 
109
 
113
 
110
     @property
114
     @property
111
     def profile(self) -> Profile:
115
     def profile(self) -> Profile:
112
-        return self.user.profile
116
+        return self.user.profile.name
113
 
117
 
114
     # Context related
118
     # Context related
115
 
119
 
227
         return self.user_role.role
231
         return self.user_role.role
228
 
232
 
229
     @property
233
     @property
234
+    def role(self) -> str:
235
+        return self.role_slug
236
+
237
+    @property
230
     def role_slug(self) -> str:
238
     def role_slug(self) -> str:
231
         """
239
         """
232
         simple name of the role of the user.
240
         simple name of the role of the user.
233
         can be anything from UserRoleInWorkspace SLUG, like
241
         can be anything from UserRoleInWorkspace SLUG, like
234
         'not_applicable', 'reader',
242
         'not_applicable', 'reader',
235
-        'contributor', 'content_manager', 'workspace_manager'
243
+        'contributor', 'content-manager', 'workspace-manager'
236
         :return: user workspace role as slug.
244
         :return: user workspace role as slug.
237
         """
245
         """
238
         return UserRoleInWorkspace.SLUG[self.user_role.role]
246
         return UserRoleInWorkspace.SLUG[self.user_role.role]
273
         self.config = config
281
         self.config = config
274
 
282
 
275
     # Default
283
     # Default
284
+    @property
285
+    def content_id(self) -> int:
286
+        return self.content.content_id
276
 
287
 
277
     @property
288
     @property
278
     def id(self) -> int:
289
     def id(self) -> int:
279
-        return self.content.content_id
290
+        return self.content_id
280
 
291
 
281
     @property
292
     @property
282
     def parent_id(self) -> int:
293
     def parent_id(self) -> int:
291
         return self.content.label
302
         return self.content.label
292
 
303
 
293
     @property
304
     @property
294
-    def content_type_slug(self) -> str:
305
+    def content_type(self) -> str:
295
         return self.content.type
306
         return self.content.type
296
 
307
 
297
     @property
308
     @property
298
-    def sub_content_type_slug(self) -> typing.List[str]:
309
+    def sub_content_types(self) -> typing.List[str]:
299
         return [type.slug for type in self.content.get_allowed_content_types()]
310
         return [type.slug for type in self.content.get_allowed_content_types()]
300
 
311
 
301
     @property
312
     @property
302
-    def status_slug(self) -> str:
313
+    def status(self) -> str:
303
         return self.content.status
314
         return self.content.status
304
 
315
 
305
     @property
316
     @property

+ 10 - 5
tracim/tests/functional/test_session.py View File

1
 # coding=utf-8
1
 # coding=utf-8
2
+import datetime
2
 import pytest
3
 import pytest
3
 from sqlalchemy.exc import OperationalError
4
 from sqlalchemy.exc import OperationalError
4
 
5
 
45
             params=params,
46
             params=params,
46
             status=200,
47
             status=200,
47
         )
48
         )
48
-        assert res.json_body['display_name'] == 'Global manager'
49
-        assert res.json_body['email'] == 'admin@admin.admin'
50
         assert res.json_body['created']
49
         assert res.json_body['created']
50
+        datetime.datetime.strptime(
51
+            res.json_body['created'],
52
+            '%Y-%m-%dT%H:%M:%SZ'
53
+        )
54
+        assert res.json_body['public_name'] == 'Global manager'
55
+        assert res.json_body['email'] == 'admin@admin.admin'
51
         assert res.json_body['is_active']
56
         assert res.json_body['is_active']
52
         assert res.json_body['profile']
57
         assert res.json_body['profile']
53
-        assert res.json_body['profile']['slug'] == 'administrators'
58
+        assert res.json_body['profile'] == 'administrators'
54
         assert res.json_body['caldav_url'] is None
59
         assert res.json_body['caldav_url'] is None
55
         assert res.json_body['avatar_url'] is None
60
         assert res.json_body['avatar_url'] is None
56
 
61
 
103
             )
108
             )
104
         )
109
         )
105
         res = self.testapp.get('/api/v2/sessions/whoami', status=200)
110
         res = self.testapp.get('/api/v2/sessions/whoami', status=200)
106
-        assert res.json_body['display_name'] == 'Global manager'
111
+        assert res.json_body['public_name'] == 'Global manager'
107
         assert res.json_body['email'] == 'admin@admin.admin'
112
         assert res.json_body['email'] == 'admin@admin.admin'
108
         assert res.json_body['created']
113
         assert res.json_body['created']
109
         assert res.json_body['is_active']
114
         assert res.json_body['is_active']
110
         assert res.json_body['profile']
115
         assert res.json_body['profile']
111
-        assert res.json_body['profile']['slug'] == 'administrators'
116
+        assert res.json_body['profile'] == 'administrators'
112
         assert res.json_body['caldav_url'] is None
117
         assert res.json_body['caldav_url'] is None
113
         assert res.json_body['avatar_url'] is None
118
         assert res.json_body['avatar_url'] is None
114
 
119
 

+ 2 - 1
tracim/tests/functional/test_user.py View File

28
         res = self.testapp.get('/api/v2/users/1/workspaces', status=200)
28
         res = self.testapp.get('/api/v2/users/1/workspaces', status=200)
29
         res = res.json_body
29
         res = res.json_body
30
         workspace = res[0]
30
         workspace = res[0]
31
-        assert workspace['id'] == 1
31
+        assert workspace['workspace_id'] == 1
32
         assert workspace['label'] == 'Business'
32
         assert workspace['label'] == 'Business'
33
+        assert workspace['slug'] == 'business'
33
         assert len(workspace['sidebar_entries']) == 7
34
         assert len(workspace['sidebar_entries']) == 7
34
 
35
 
35
         sidebar_entry = workspace['sidebar_entries'][0]
36
         sidebar_entry = workspace['sidebar_entries'][0]

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

27
         )
27
         )
28
         res = self.testapp.get('/api/v2/workspaces/1', status=200)
28
         res = self.testapp.get('/api/v2/workspaces/1', status=200)
29
         workspace = res.json_body
29
         workspace = res.json_body
30
-        assert workspace['id'] == 1
30
+        assert workspace['workspace_id'] == 1
31
         assert workspace['slug'] == 'business'
31
         assert workspace['slug'] == 'business'
32
         assert workspace['label'] == 'Business'
32
         assert workspace['label'] == 'Business'
33
         assert workspace['description'] == 'All importants documents'
33
         assert workspace['description'] == 'All importants documents'
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']['public_name'] == 'Global manager'
162
         # TODO - G.M - 24-05-2018 - [Avatar] Replace
162
         # TODO - G.M - 24-05-2018 - [Avatar] Replace
163
         # by correct value when avatar feature will be enabled
163
         # by correct value when avatar feature will be enabled
164
         assert user_role['user']['avatar_url'] is None
164
         assert user_role['user']['avatar_url'] is None
239
         # TODO - G.M - 30-05-2018 - Check this test
239
         # TODO - G.M - 30-05-2018 - Check this test
240
         assert len(res) == 3
240
         assert len(res) == 3
241
         content = res[0]
241
         content = res[0]
242
-        assert content['id'] == 1
242
+        assert content['content_id'] == 1
243
         assert content['is_archived'] is False
243
         assert content['is_archived'] is False
244
         assert content['is_deleted'] is False
244
         assert content['is_deleted'] is False
245
         assert content['label'] == 'Tools'
245
         assert content['label'] == 'Tools'
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'
250
-        assert set(content['sub_content_type_slug']) == {'thread', 'page', 'folder', 'file'}  # nopep8
249
+        assert content['status'] == 'open'
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]
253
-        assert content['id'] == 2
253
+        assert content['content_id'] == 2
254
         assert content['is_archived'] is False
254
         assert content['is_archived'] is False
255
         assert content['is_deleted'] is False
255
         assert content['is_deleted'] is False
256
         assert content['label'] == 'Menus'
256
         assert content['label'] == 'Menus'
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'
261
-        assert set(content['sub_content_type_slug']) == {'thread', 'page', 'folder', 'file'}  # nopep8
260
+        assert content['status'] == 'open'
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]
264
-        assert content['id'] == 11
264
+        assert content['content_id'] == 11
265
         assert content['is_archived'] is False
265
         assert content['is_archived'] is False
266
         assert content['is_deleted'] is False
266
         assert content['is_deleted'] is False
267
         assert content['label'] == 'Current Menu'
267
         assert content['label'] == 'Current Menu'
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'
272
-        assert set(content['sub_content_type_slug']) == {'thread', 'page', 'folder', 'file'}  # nopep8
271
+        assert content['status'] == 'open'
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
 
275
     # Root related
275
     # Root related
299
         # TODO - G.M - 30-05-2018 - Check this test
299
         # TODO - G.M - 30-05-2018 - Check this test
300
         assert len(res) == 4
300
         assert len(res) == 4
301
         content = res[1]
301
         content = res[1]
302
-        assert content['content_type_slug'] == 'page'
303
-        assert content['id'] == 15
302
+        assert content['content_type'] == 'page'
303
+        assert content['content_id'] == 15
304
         assert content['is_archived'] is False
304
         assert content['is_archived'] is False
305
         assert content['is_deleted'] is False
305
         assert content['is_deleted'] is False
306
         assert content['label'] == 'New Fruit Salad'
306
         assert content['label'] == 'New Fruit Salad'
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'
311
-        assert set(content['sub_content_type_slug']) == {'thread', 'page', 'folder', 'file'}  # nopep8
310
+        assert content['status'] == 'open'
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
 
314
         content = res[2]
314
         content = res[2]
315
-        assert content['content_type_slug'] == 'page'
316
-        assert content['id'] == 16
315
+        assert content['content_type'] == 'page'
316
+        assert content['content_id'] == 16
317
         assert content['is_archived'] is True
317
         assert content['is_archived'] is True
318
         assert content['is_deleted'] is False
318
         assert content['is_deleted'] is False
319
         assert content['label'].startswith('Fruit Salad')
319
         assert content['label'].startswith('Fruit Salad')
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'
324
-        assert set(content['sub_content_type_slug']) == {'thread', 'page', 'folder', 'file'}  # nopep8
323
+        assert content['status'] == 'open'
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
 
327
         content = res[3]
327
         content = res[3]
328
-        assert content['content_type_slug'] == 'page'
329
-        assert content['id'] == 17
328
+        assert content['content_type'] == 'page'
329
+        assert content['content_id'] == 17
330
         assert content['is_archived'] is False
330
         assert content['is_archived'] is False
331
         assert content['is_deleted'] is True
331
         assert content['is_deleted'] is True
332
         assert content['label'].startswith('Bad Fruit Salad')
332
         assert content['label'].startswith('Bad Fruit Salad')
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'
337
-        assert set(content['sub_content_type_slug']) == {'thread', 'page', 'folder', 'file'}  # nopep8
336
+        assert content['status'] == 'open'
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
 
340
     def test_api__get_workspace_content__ok_200__get_only_active_root_content(self):  # nopep8
340
     def test_api__get_workspace_content__ok_200__get_only_active_root_content(self):  # nopep8
362
         # TODO - G.M - 30-05-2018 - Check this test
362
         # TODO - G.M - 30-05-2018 - Check this test
363
         assert len(res) == 2
363
         assert len(res) == 2
364
         content = res[1]
364
         content = res[1]
365
-        assert content['content_type_slug'] == 'page'
366
-        assert content['id'] == 15
365
+        assert content['content_type'] == 'page'
366
+        assert content['content_id'] == 15
367
         assert content['is_archived'] is False
367
         assert content['is_archived'] is False
368
         assert content['is_deleted'] is False
368
         assert content['is_deleted'] is False
369
         assert content['label'] == 'New Fruit Salad'
369
         assert content['label'] == 'New Fruit Salad'
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'
374
-        assert set(content['sub_content_type_slug']) == {'thread', 'page', 'folder', 'file'}  # nopep8
373
+        assert content['status'] == 'open'
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
 
377
     def test_api__get_workspace_content__ok_200__get_only_archived_root_content(self):  # nopep8
377
     def test_api__get_workspace_content__ok_200__get_only_archived_root_content(self):  # nopep8
398
         ).json_body   # nopep8
398
         ).json_body   # nopep8
399
         assert len(res) == 1
399
         assert len(res) == 1
400
         content = res[0]
400
         content = res[0]
401
-        assert content['content_type_slug'] == 'page'
402
-        assert content['id'] == 16
401
+        assert content['content_type'] == 'page'
402
+        assert content['content_id'] == 16
403
         assert content['is_archived'] is True
403
         assert content['is_archived'] is True
404
         assert content['is_deleted'] is False
404
         assert content['is_deleted'] is False
405
         assert content['label'].startswith('Fruit Salad')
405
         assert content['label'].startswith('Fruit Salad')
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'
410
-        assert set(content['sub_content_type_slug']) == {'thread', 'page', 'folder', 'file'}  # nopep8
409
+        assert content['status'] == 'open'
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
 
413
     def test_api__get_workspace_content__ok_200__get_only_deleted_root_content(self):  # nopep8
413
     def test_api__get_workspace_content__ok_200__get_only_deleted_root_content(self):  # nopep8
436
 
436
 
437
         assert len(res) == 1
437
         assert len(res) == 1
438
         content = res[0]
438
         content = res[0]
439
-        assert content['content_type_slug'] == 'page'
440
-        assert content['id'] == 17
439
+        assert content['content_type'] == 'page'
440
+        assert content['content_id'] == 17
441
         assert content['is_archived'] is False
441
         assert content['is_archived'] is False
442
         assert content['is_deleted'] is True
442
         assert content['is_deleted'] is True
443
         assert content['label'].startswith('Bad Fruit Salad')
443
         assert content['label'].startswith('Bad Fruit Salad')
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'
448
-        assert set(content['sub_content_type_slug']) == {'thread', 'page', 'folder', 'file'}  # nopep8
447
+        assert content['status'] == 'open'
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
 
451
     def test_api__get_workspace_content__ok_200__get_nothing_root_content(self):
451
     def test_api__get_workspace_content__ok_200__get_nothing_root_content(self):
500
         ).json_body   # nopep8
500
         ).json_body   # nopep8
501
         assert len(res) == 3
501
         assert len(res) == 3
502
         content = res[0]
502
         content = res[0]
503
-        assert content['content_type_slug'] == 'page'
504
-        assert content['id'] == 12
503
+        assert content['content_type'] == 'page'
504
+        assert content['content_id'] == 12
505
         assert content['is_archived'] is False
505
         assert content['is_archived'] is False
506
         assert content['is_deleted'] is False
506
         assert content['is_deleted'] is False
507
         assert content['label'] == 'New Fruit Salad'
507
         assert content['label'] == 'New Fruit Salad'
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'
512
-        assert set(content['sub_content_type_slug']) == {'thread', 'page', 'folder', 'file'}  # nopep8
511
+        assert content['status'] == 'open'
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
 
515
         content = res[1]
515
         content = res[1]
516
-        assert content['content_type_slug'] == 'page'
517
-        assert content['id'] == 13
516
+        assert content['content_type'] == 'page'
517
+        assert content['content_id'] == 13
518
         assert content['is_archived'] is True
518
         assert content['is_archived'] is True
519
         assert content['is_deleted'] is False
519
         assert content['is_deleted'] is False
520
         assert content['label'].startswith('Fruit Salad')
520
         assert content['label'].startswith('Fruit Salad')
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'
525
-        assert set(content['sub_content_type_slug']) == {'thread', 'page', 'folder', 'file'}  # nopep8
524
+        assert content['status'] == 'open'
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
 
528
         content = res[2]
528
         content = res[2]
529
-        assert content['content_type_slug'] == 'page'
530
-        assert content['id'] == 14
529
+        assert content['content_type'] == 'page'
530
+        assert content['content_id'] == 14
531
         assert content['is_archived'] is False
531
         assert content['is_archived'] is False
532
         assert content['is_deleted'] is True
532
         assert content['is_deleted'] is True
533
         assert content['label'].startswith('Bad Fruit Salad')
533
         assert content['label'].startswith('Bad Fruit Salad')
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'
538
-        assert set(content['sub_content_type_slug']) == {'thread', 'page', 'folder', 'file'}  # nopep8
537
+        assert content['status'] == 'open'
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
 
541
     def test_api__get_workspace_content__ok_200__get_only_active_folder_content(self):  # nopep8
541
     def test_api__get_workspace_content__ok_200__get_only_active_folder_content(self):  # nopep8
562
         ).json_body   # nopep8
562
         ).json_body   # nopep8
563
         assert len(res) == 1
563
         assert len(res) == 1
564
         content = res[0]
564
         content = res[0]
565
-        assert content['content_type_slug']
566
-        assert content['id'] == 12
565
+        assert content['content_type']
566
+        assert content['content_id'] == 12
567
         assert content['is_archived'] is False
567
         assert content['is_archived'] is False
568
         assert content['is_deleted'] is False
568
         assert content['is_deleted'] is False
569
         assert content['label'] == 'New Fruit Salad'
569
         assert content['label'] == 'New Fruit Salad'
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'
574
-        assert set(content['sub_content_type_slug']) == {'thread', 'page', 'folder', 'file'}  # nopep8
573
+        assert content['status'] == 'open'
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
 
577
     def test_api__get_workspace_content__ok_200__get_only_archived_folder_content(self):  # nopep8
577
     def test_api__get_workspace_content__ok_200__get_only_archived_folder_content(self):  # nopep8
598
         ).json_body   # nopep8
598
         ).json_body   # nopep8
599
         assert len(res) == 1
599
         assert len(res) == 1
600
         content = res[0]
600
         content = res[0]
601
-        assert content['content_type_slug'] == 'page'
602
-        assert content['id'] == 13
601
+        assert content['content_type'] == 'page'
602
+        assert content['content_id'] == 13
603
         assert content['is_archived'] is True
603
         assert content['is_archived'] is True
604
         assert content['is_deleted'] is False
604
         assert content['is_deleted'] is False
605
         assert content['label'].startswith('Fruit Salad')
605
         assert content['label'].startswith('Fruit Salad')
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'
610
-        assert set(content['sub_content_type_slug']) == {'thread', 'page', 'folder', 'file'}  # nopep8
609
+        assert content['status'] == 'open'
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
 
613
     def test_api__get_workspace_content__ok_200__get_only_deleted_folder_content(self):  # nopep8
613
     def test_api__get_workspace_content__ok_200__get_only_deleted_folder_content(self):  # nopep8
635
 
635
 
636
         assert len(res) == 1
636
         assert len(res) == 1
637
         content = res[0]
637
         content = res[0]
638
-        assert content['content_type_slug'] == 'page'
639
-        assert content['id'] == 14
638
+        assert content['content_type'] == 'page'
639
+        assert content['content_id'] == 14
640
         assert content['is_archived'] is False
640
         assert content['is_archived'] is False
641
         assert content['is_deleted'] is True
641
         assert content['is_deleted'] is True
642
         assert content['label'].startswith('Bad Fruit Salad')
642
         assert content['label'].startswith('Bad Fruit Salad')
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'
647
-        assert set(content['sub_content_type_slug']) == {'thread', 'page', 'folder', 'file'}  # nopep8
646
+        assert content['status'] == 'open'
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
 
650
     def test_api__get_workspace_content__ok_200__get_nothing_folder_content(self):  # nopep8
650
     def test_api__get_workspace_content__ok_200__get_nothing_folder_content(self):  # nopep8
741
         )
741
         )
742
         params = {
742
         params = {
743
             'label': 'GenericCreatedContent',
743
             'label': 'GenericCreatedContent',
744
-            'content_type_slug': 'markdownpage',
744
+            'content_type': 'markdownpage',
745
         }
745
         }
746
         res = self.testapp.post_json(
746
         res = self.testapp.post_json(
747
             '/api/v2/workspaces/1/contents',
747
             '/api/v2/workspaces/1/contents',
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'
754
-        assert res.json_body['id']
755
-        assert res.json_body['content_type_slug'] == 'markdownpage'
753
+        assert res.json_body['status'] == 'open'
754
+        assert res.json_body['content_id']
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
757
         assert res.json_body['is_deleted'] is False
757
         assert res.json_body['is_deleted'] is False
758
         assert res.json_body['workspace_id'] == 1
758
         assert res.json_body['workspace_id'] == 1
759
         assert res.json_body['slug'] == 'genericcreatedcontent'
759
         assert res.json_body['slug'] == 'genericcreatedcontent'
760
         assert res.json_body['parent_id'] is None
760
         assert res.json_body['parent_id'] is None
761
         assert res.json_body['show_in_ui'] is True
761
         assert res.json_body['show_in_ui'] is True
762
-        assert res.json_body['sub_content_type_slug']
762
+        assert res.json_body['sub_content_types']
763
         params_active = {
763
         params_active = {
764
             'parent_id': 0,
764
             'parent_id': 0,
765
             'show_archived': 0,
765
             'show_archived': 0,
801
         }
801
         }
802
         folder1_contents = self.testapp.get('/api/v2/workspaces/2/contents', params=params_folder1, status=200).json_body  # nopep8
802
         folder1_contents = self.testapp.get('/api/v2/workspaces/2/contents', params=params_folder1, status=200).json_body  # nopep8
803
         folder2_contents = self.testapp.get('/api/v2/workspaces/2/contents', params=params_folder2, status=200).json_body  # nopep8
803
         folder2_contents = self.testapp.get('/api/v2/workspaces/2/contents', params=params_folder2, status=200).json_body  # nopep8
804
-        assert [content for content in folder1_contents if content['id'] == 8]  # nopep8
805
-        assert not [content for content in folder2_contents if content['id'] == 8]  # nopep8
804
+        assert [content for content in folder1_contents if content['content_id'] == 8]  # nopep8
805
+        assert not [content for content in folder2_contents if content['content_id'] == 8]  # nopep8
806
         # TODO - G.M - 2018-06-163 - Check content
806
         # TODO - G.M - 2018-06-163 - Check content
807
         res = self.testapp.put_json(
807
         res = self.testapp.put_json(
808
             '/api/v2/workspaces/2/contents/8/move',
808
             '/api/v2/workspaces/2/contents/8/move',
809
             params=params,
809
             params=params,
810
-            status=200
810
+            status=204
811
         )
811
         )
812
         new_folder1_contents = self.testapp.get('/api/v2/workspaces/2/contents', params=params_folder1, status=200).json_body  # nopep8
812
         new_folder1_contents = self.testapp.get('/api/v2/workspaces/2/contents', params=params_folder1, status=200).json_body  # nopep8
813
         new_folder2_contents = self.testapp.get('/api/v2/workspaces/2/contents', params=params_folder2, status=200).json_body  # nopep8
813
         new_folder2_contents = self.testapp.get('/api/v2/workspaces/2/contents', params=params_folder2, status=200).json_body  # nopep8
814
-        assert not [content for content in new_folder1_contents if content['id'] == 8]  # nopep8
815
-        assert [content for content in new_folder2_contents if content['id'] == 8]  # nopep8
814
+        assert not [content for content in new_folder1_contents if content['content_id'] == 8]  # nopep8
815
+        assert [content for content in new_folder2_contents if content['content_id'] == 8]  # nopep8
816
 
816
 
817
     def test_api_put_move_content__ok_200__to_root(self):
817
     def test_api_put_move_content__ok_200__to_root(self):
818
         """
818
         """
1055
         }
1055
         }
1056
         active_contents = self.testapp.get('/api/v2/workspaces/2/contents', params=params_active, status=200).json_body  # nopep8
1056
         active_contents = self.testapp.get('/api/v2/workspaces/2/contents', params=params_active, status=200).json_body  # nopep8
1057
         deleted_contents = self.testapp.get('/api/v2/workspaces/2/contents', params=params_deleted, status=200).json_body  # nopep8
1057
         deleted_contents = self.testapp.get('/api/v2/workspaces/2/contents', params=params_deleted, status=200).json_body  # nopep8
1058
-        assert [content for content in active_contents if content['id'] == 8]  # nopep8
1059
-        assert not [content for content in deleted_contents if content['id'] == 8]  # nopep8
1058
+        assert [content for content in active_contents if content['content_id'] == 8]  # nopep8
1059
+        assert not [content for content in deleted_contents if content['content_id'] == 8]  # nopep8
1060
         # TODO - G.M - 2018-06-163 - Check content
1060
         # TODO - G.M - 2018-06-163 - Check content
1061
         res = self.testapp.put_json(
1061
         res = self.testapp.put_json(
1062
             # INFO - G.M - 2018-06-163 - delete Apple_Pie
1062
             # INFO - G.M - 2018-06-163 - delete Apple_Pie
1063
             '/api/v2/workspaces/2/contents/8/delete',
1063
             '/api/v2/workspaces/2/contents/8/delete',
1064
-            status=200
1064
+            status=204
1065
         )
1065
         )
1066
         new_active_contents = self.testapp.get('/api/v2/workspaces/2/contents', params=params_active, status=200).json_body  # nopep8
1066
         new_active_contents = self.testapp.get('/api/v2/workspaces/2/contents', params=params_active, status=200).json_body  # nopep8
1067
         new_deleted_contents = self.testapp.get('/api/v2/workspaces/2/contents', params=params_deleted, status=200).json_body  # nopep8
1067
         new_deleted_contents = self.testapp.get('/api/v2/workspaces/2/contents', params=params_deleted, status=200).json_body  # nopep8
1068
-        assert not [content for content in new_active_contents if content['id'] == 8]  # nopep8
1069
-        assert [content for content in new_deleted_contents if content['id'] == 8]  # nopep8
1068
+        assert not [content for content in new_active_contents if content['content_id'] == 8]  # nopep8
1069
+        assert [content for content in new_deleted_contents if content['content_id'] == 8]  # nopep8
1070
 
1070
 
1071
     def test_api_put_archive_content__ok_200__nominal_case(self):
1071
     def test_api_put_archive_content__ok_200__nominal_case(self):
1072
         """
1072
         """
1094
         }
1094
         }
1095
         active_contents = self.testapp.get('/api/v2/workspaces/2/contents', params=params_active, status=200).json_body  # nopep8
1095
         active_contents = self.testapp.get('/api/v2/workspaces/2/contents', params=params_active, status=200).json_body  # nopep8
1096
         archived_contents = self.testapp.get('/api/v2/workspaces/2/contents', params=params_archived, status=200).json_body  # nopep8
1096
         archived_contents = self.testapp.get('/api/v2/workspaces/2/contents', params=params_archived, status=200).json_body  # nopep8
1097
-        assert [content for content in active_contents if content['id'] == 8]  # nopep8
1098
-        assert not [content for content in archived_contents if content['id'] == 8]  # nopep8
1097
+        assert [content for content in active_contents if content['content_id'] == 8]  # nopep8
1098
+        assert not [content for content in archived_contents if content['content_id'] == 8]  # nopep8
1099
         res = self.testapp.put_json(
1099
         res = self.testapp.put_json(
1100
             '/api/v2/workspaces/2/contents/8/archive',
1100
             '/api/v2/workspaces/2/contents/8/archive',
1101
-            status=200
1101
+            status=204
1102
         )
1102
         )
1103
         new_active_contents = self.testapp.get('/api/v2/workspaces/2/contents', params=params_active, status=200).json_body  # nopep8
1103
         new_active_contents = self.testapp.get('/api/v2/workspaces/2/contents', params=params_active, status=200).json_body  # nopep8
1104
         new_archived_contents = self.testapp.get('/api/v2/workspaces/2/contents', params=params_archived, status=200).json_body  # nopep8
1104
         new_archived_contents = self.testapp.get('/api/v2/workspaces/2/contents', params=params_archived, status=200).json_body  # nopep8
1105
-        assert not [content for content in new_active_contents if content['id'] == 8]  # nopep8
1106
-        assert [content for content in new_archived_contents if content['id'] == 8]  # nopep8
1105
+        assert not [content for content in new_active_contents if content['content_id'] == 8]  # nopep8
1106
+        assert [content for content in new_archived_contents if content['content_id'] == 8]  # nopep8
1107
 
1107
 
1108
     def test_api_put_undelete_content__ok_200__nominal_case(self):
1108
     def test_api_put_undelete_content__ok_200__nominal_case(self):
1109
         """
1109
         """
1131
         }
1131
         }
1132
         active_contents = self.testapp.get('/api/v2/workspaces/2/contents', params=params_active, status=200).json_body  # nopep8
1132
         active_contents = self.testapp.get('/api/v2/workspaces/2/contents', params=params_active, status=200).json_body  # nopep8
1133
         deleted_contents = self.testapp.get('/api/v2/workspaces/2/contents', params=params_deleted, status=200).json_body  # nopep8
1133
         deleted_contents = self.testapp.get('/api/v2/workspaces/2/contents', params=params_deleted, status=200).json_body  # nopep8
1134
-        assert not [content for content in active_contents if content['id'] == 14]  # nopep8
1135
-        assert [content for content in deleted_contents if content['id'] == 14]  # nopep8
1134
+        assert not [content for content in active_contents if content['content_id'] == 14]  # nopep8
1135
+        assert [content for content in deleted_contents if content['content_id'] == 14]  # nopep8
1136
         res = self.testapp.put_json(
1136
         res = self.testapp.put_json(
1137
             '/api/v2/workspaces/2/contents/14/undelete',
1137
             '/api/v2/workspaces/2/contents/14/undelete',
1138
-            status=200
1138
+            status=204
1139
         )
1139
         )
1140
         new_active_contents = self.testapp.get('/api/v2/workspaces/2/contents', params=params_active, status=200).json_body  # nopep8
1140
         new_active_contents = self.testapp.get('/api/v2/workspaces/2/contents', params=params_active, status=200).json_body  # nopep8
1141
         new_deleted_contents = self.testapp.get('/api/v2/workspaces/2/contents', params=params_deleted, status=200).json_body  # nopep8
1141
         new_deleted_contents = self.testapp.get('/api/v2/workspaces/2/contents', params=params_deleted, status=200).json_body  # nopep8
1142
-        assert [content for content in new_active_contents if content['id'] == 14]  # nopep8
1143
-        assert not [content for content in new_deleted_contents if content['id'] == 14]  # nopep8
1142
+        assert [content for content in new_active_contents if content['content_id'] == 14]  # nopep8
1143
+        assert not [content for content in new_deleted_contents if content['content_id'] == 14]  # nopep8
1144
 
1144
 
1145
     def test_api_put_unarchive_content__ok_200__nominal_case(self):
1145
     def test_api_put_unarchive_content__ok_200__nominal_case(self):
1146
         """
1146
         """
1168
         }
1168
         }
1169
         active_contents = self.testapp.get('/api/v2/workspaces/2/contents', params=params_active, status=200).json_body  # nopep8
1169
         active_contents = self.testapp.get('/api/v2/workspaces/2/contents', params=params_active, status=200).json_body  # nopep8
1170
         archived_contents = self.testapp.get('/api/v2/workspaces/2/contents', params=params_archived, status=200).json_body  # nopep8
1170
         archived_contents = self.testapp.get('/api/v2/workspaces/2/contents', params=params_archived, status=200).json_body  # nopep8
1171
-        assert not [content for content in active_contents if content['id'] == 13]  # nopep8
1172
-        assert [content for content in archived_contents if content['id'] == 13]  # nopep8
1171
+        assert not [content for content in active_contents if content['content_id'] == 13]  # nopep8
1172
+        assert [content for content in archived_contents if content['content_id'] == 13]  # nopep8
1173
         res = self.testapp.put_json(
1173
         res = self.testapp.put_json(
1174
             '/api/v2/workspaces/2/contents/13/unarchive',
1174
             '/api/v2/workspaces/2/contents/13/unarchive',
1175
-            status=200
1175
+            status=204
1176
         )
1176
         )
1177
         new_active_contents = self.testapp.get('/api/v2/workspaces/2/contents', params=params_active, status=200).json_body  # nopep8
1177
         new_active_contents = self.testapp.get('/api/v2/workspaces/2/contents', params=params_active, status=200).json_body  # nopep8
1178
         new_archived_contents = self.testapp.get('/api/v2/workspaces/2/contents', params=params_archived, status=200).json_body  # nopep8
1178
         new_archived_contents = self.testapp.get('/api/v2/workspaces/2/contents', params=params_archived, status=200).json_body  # nopep8
1179
-        assert [content for content in new_active_contents if content['id'] == 13]  # nopep8
1180
-        assert not [content for content in new_archived_contents if content['id'] == 13]  # nopep8
1179
+        assert [content for content in new_active_contents if content['content_id'] == 13]  # nopep8
1180
+        assert not [content for content in new_archived_contents if content['content_id'] == 13]  # nopep8

+ 1 - 1
tracim/tests/library/test_user_api.py View File

131
         new_user = api.get_user_with_context(user)
131
         new_user = api.get_user_with_context(user)
132
         assert isinstance(new_user, UserInContext)
132
         assert isinstance(new_user, UserInContext)
133
         assert new_user.user == user
133
         assert new_user.user == user
134
-        assert new_user.profile.name == 'nobody'
134
+        assert new_user.profile == 'nobody'
135
         assert new_user.user_id == user.user_id
135
         assert new_user.user_id == user.user_id
136
         assert new_user.email == 'admin@tracim.tracim'
136
         assert new_user.email == 'admin@tracim.tracim'
137
         assert new_user.display_name == 'Admin'
137
         assert new_user.display_name == 'Admin'

+ 17 - 27
tracim/views/core_api/schemas.py View File

16
 from tracim.models.data import UserRoleInWorkspace
16
 from tracim.models.data import UserRoleInWorkspace
17
 
17
 
18
 
18
 
19
-class ProfileSchema(marshmallow.Schema):
20
-    slug = marshmallow.fields.String(
21
-        attribute='name',
22
-        validate=OneOf(Profile._NAME),
23
-        example='managers',
24
-    )
25
-
26
-    class Meta:
27
-        description = 'User Profile, give user right on whole Tracim instance.'
28
-
29
-
30
 class UserSchema(marshmallow.Schema):
19
 class UserSchema(marshmallow.Schema):
31
 
20
 
32
     user_id = marshmallow.fields.Int(dump_only=True, example=3)
21
     user_id = marshmallow.fields.Int(dump_only=True, example=3)
34
         required=True,
23
         required=True,
35
         example='suri.cate@algoo.fr'
24
         example='suri.cate@algoo.fr'
36
     )
25
     )
37
-    display_name = marshmallow.fields.String(
26
+    public_name = marshmallow.fields.String(
38
         example='Suri Cate',
27
         example='Suri Cate',
39
     )
28
     )
40
     created = marshmallow.fields.DateTime(
29
     created = marshmallow.fields.DateTime(
41
-        format='iso8601',
42
-        description='User account creation date (iso8601 format).',
30
+        format='%Y-%m-%dT%H:%M:%SZ',
31
+        description='User account creation date',
43
     )
32
     )
44
     is_active = marshmallow.fields.Bool(
33
     is_active = marshmallow.fields.Bool(
45
         example=True,
34
         example=True,
64
                     "If no avatar, then set it to null "
53
                     "If no avatar, then set it to null "
65
                     "(and frontend will interpret this with a default avatar)",
54
                     "(and frontend will interpret this with a default avatar)",
66
     )
55
     )
67
-    profile = marshmallow.fields.Nested(
68
-        ProfileSchema,
69
-        many=False,
56
+    profile = marshmallow.fields.String(
57
+        attribute='profile',
58
+        validate=OneOf(Profile._NAME),
59
+        example='managers',
70
     )
60
     )
71
 
61
 
72
     class Meta:
62
     class Meta:
187
 
177
 
188
 
178
 
189
 class WorkspaceDigestSchema(marshmallow.Schema):
179
 class WorkspaceDigestSchema(marshmallow.Schema):
190
-    id = marshmallow.fields.Int(example=4)
180
+    workspace_id = marshmallow.fields.Int(example=4)
181
+    slug = marshmallow.fields.String(example='intranet')
191
     label = marshmallow.fields.String(example='Intranet')
182
     label = marshmallow.fields.String(example='Intranet')
192
     sidebar_entries = marshmallow.fields.Nested(
183
     sidebar_entries = marshmallow.fields.Nested(
193
         WorkspaceMenuEntrySchema,
184
         WorkspaceMenuEntrySchema,
199
 
190
 
200
 
191
 
201
 class WorkspaceSchema(WorkspaceDigestSchema):
192
 class WorkspaceSchema(WorkspaceDigestSchema):
202
-    slug = marshmallow.fields.String(example='intranet')
203
     description = marshmallow.fields.String(example='All intranet data.')
193
     description = marshmallow.fields.String(example='All intranet data.')
204
 
194
 
205
     class Meta:
195
     class Meta:
207
 
197
 
208
 
198
 
209
 class WorkspaceMemberSchema(marshmallow.Schema):
199
 class WorkspaceMemberSchema(marshmallow.Schema):
210
-    role_slug = marshmallow.fields.String(
200
+    role = marshmallow.fields.String(
211
         example='contributor',
201
         example='contributor',
212
         validate=OneOf(UserRoleInWorkspace.get_all_role_slug())
202
         validate=OneOf(UserRoleInWorkspace.get_all_role_slug())
213
     )
203
     )
214
     user_id = marshmallow.fields.Int(example=3)
204
     user_id = marshmallow.fields.Int(example=3)
215
     workspace_id = marshmallow.fields.Int(example=4)
205
     workspace_id = marshmallow.fields.Int(example=4)
216
     user = marshmallow.fields.Nested(
206
     user = marshmallow.fields.Nested(
217
-        UserSchema(only=('display_name', 'avatar_url'))
207
+        UserSchema(only=('public_name', 'avatar_url'))
218
     )
208
     )
219
 
209
 
220
     class Meta:
210
     class Meta:
256
                     'Statuses are open, closed-validated, closed-invalidated, closed-deprecated'  # nopep8
246
                     'Statuses are open, closed-validated, closed-invalidated, closed-deprecated'  # nopep8
257
     )
247
     )
258
     global_status = marshmallow.fields.String(
248
     global_status = marshmallow.fields.String(
259
-        example='Open',
249
+        example='open',
260
         description='global_status: open, closed',
250
         description='global_status: open, closed',
261
         validate=OneOf([status.value for status in GlobalStatus]),
251
         validate=OneOf([status.value for status in GlobalStatus]),
262
     )
252
     )
317
         example='contract for client XXX',
307
         example='contract for client XXX',
318
         description='Title of the content to create'
308
         description='Title of the content to create'
319
     )
309
     )
320
-    content_type_slug = marshmallow.fields.String(
310
+    content_type = marshmallow.fields.String(
321
         example='htmlpage',
311
         example='htmlpage',
322
         validate=OneOf([content.slug for content in CONTENT_DEFAULT_TYPE]),
312
         validate=OneOf([content.slug for content in CONTENT_DEFAULT_TYPE]),
323
     )
313
     )
328
 
318
 
329
 
319
 
330
 class ContentDigestSchema(marshmallow.Schema):
320
 class ContentDigestSchema(marshmallow.Schema):
331
-    id = marshmallow.fields.Int(example=6)
321
+    content_id = marshmallow.fields.Int(example=6)
332
     slug = marshmallow.fields.Str(example='intervention-report-12')
322
     slug = marshmallow.fields.Str(example='intervention-report-12')
333
     parent_id = marshmallow.fields.Int(
323
     parent_id = marshmallow.fields.Int(
334
         example=34,
324
         example=34,
339
         example=19,
329
         example=19,
340
     )
330
     )
341
     label = marshmallow.fields.Str(example='Intervention Report 12')
331
     label = marshmallow.fields.Str(example='Intervention Report 12')
342
-    content_type_slug = marshmallow.fields.Str(
332
+    content_type = marshmallow.fields.Str(
343
         example='htmlpage',
333
         example='htmlpage',
344
         validate=OneOf([content.slug for content in CONTENT_DEFAULT_TYPE]),
334
         validate=OneOf([content.slug for content in CONTENT_DEFAULT_TYPE]),
345
     )
335
     )
346
-    sub_content_type_slug = marshmallow.fields.List(
336
+    sub_content_types = marshmallow.fields.List(
347
         marshmallow.fields.Str,
337
         marshmallow.fields.Str,
348
         description='list of content types allowed as sub contents. '
338
         description='list of content types allowed as sub contents. '
349
                     'This field is required for folder contents, '
339
                     'This field is required for folder contents, '
350
                     'set it to empty list in other cases'
340
                     'set it to empty list in other cases'
351
     )
341
     )
352
-    status_slug = marshmallow.fields.Str(
342
+    status = marshmallow.fields.Str(
353
         example='closed-deprecated',
343
         example='closed-deprecated',
354
         validate=OneOf([status.slug for status in CONTENT_DEFAULT_STATUS]),
344
         validate=OneOf([status.slug for status in CONTENT_DEFAULT_STATUS]),
355
         description='this slug is found in content_type available statuses',
345
         description='this slug is found in content_type available statuses',

+ 6 - 6
tracim/views/core_api/workspace_controller.py View File

149
         )
149
         )
150
         content = api.create(
150
         content = api.create(
151
             label=creation_data.label,
151
             label=creation_data.label,
152
-            content_type=creation_data.content_type_slug,
152
+            content_type=creation_data.content_type,
153
             workspace=request.current_workspace,
153
             workspace=request.current_workspace,
154
         )
154
         )
155
         api.save(content, ActionDescription.CREATION)
155
         api.save(content, ActionDescription.CREATION)
166
     @require_candidate_workspace_role(UserRoleInWorkspace.CONTRIBUTOR)
166
     @require_candidate_workspace_role(UserRoleInWorkspace.CONTRIBUTOR)
167
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
167
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
168
     @hapic.input_body(ContentMoveSchema())
168
     @hapic.input_body(ContentMoveSchema())
169
-    @hapic.output_body(NoContentSchema())
169
+    @hapic.output_body(NoContentSchema(), default_http_code=HTTPStatus.NO_CONTENT)  # nopep8
170
     def move_content(
170
     def move_content(
171
             self,
171
             self,
172
             context,
172
             context,
217
     @hapic.handle_exception(WorkspaceNotFound, HTTPStatus.FORBIDDEN)
217
     @hapic.handle_exception(WorkspaceNotFound, HTTPStatus.FORBIDDEN)
218
     @require_workspace_role(UserRoleInWorkspace.CONTRIBUTOR)
218
     @require_workspace_role(UserRoleInWorkspace.CONTRIBUTOR)
219
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
219
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
220
-    @hapic.output_body(NoContentSchema())
220
+    @hapic.output_body(NoContentSchema(), default_http_code=HTTPStatus.NO_CONTENT)  # nopep8
221
     def delete_content(
221
     def delete_content(
222
             self,
222
             self,
223
             context,
223
             context,
252
     @hapic.handle_exception(WorkspaceNotFound, HTTPStatus.FORBIDDEN)
252
     @hapic.handle_exception(WorkspaceNotFound, HTTPStatus.FORBIDDEN)
253
     @require_workspace_role(UserRoleInWorkspace.CONTRIBUTOR)
253
     @require_workspace_role(UserRoleInWorkspace.CONTRIBUTOR)
254
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
254
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
255
-    @hapic.output_body(NoContentSchema())
255
+    @hapic.output_body(NoContentSchema(), default_http_code=HTTPStatus.NO_CONTENT)  # nopep8
256
     def undelete_content(
256
     def undelete_content(
257
             self,
257
             self,
258
             context,
258
             context,
288
     @hapic.handle_exception(WorkspaceNotFound, HTTPStatus.FORBIDDEN)
288
     @hapic.handle_exception(WorkspaceNotFound, HTTPStatus.FORBIDDEN)
289
     @require_workspace_role(UserRoleInWorkspace.CONTRIBUTOR)
289
     @require_workspace_role(UserRoleInWorkspace.CONTRIBUTOR)
290
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
290
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
291
-    @hapic.output_body(NoContentSchema())
291
+    @hapic.output_body(NoContentSchema(), default_http_code=HTTPStatus.NO_CONTENT)  # nopep8
292
     def archive_content(
292
     def archive_content(
293
             self,
293
             self,
294
             context,
294
             context,
320
     @hapic.handle_exception(WorkspaceNotFound, HTTPStatus.FORBIDDEN)
320
     @hapic.handle_exception(WorkspaceNotFound, HTTPStatus.FORBIDDEN)
321
     @require_workspace_role(UserRoleInWorkspace.CONTRIBUTOR)
321
     @require_workspace_role(UserRoleInWorkspace.CONTRIBUTOR)
322
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
322
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
323
-    @hapic.output_body(NoContentSchema())
323
+    @hapic.output_body(NoContentSchema(), default_http_code=HTTPStatus.NO_CONTENT)  # nopep8
324
     def unarchive_content(
324
     def unarchive_content(
325
             self,
325
             self,
326
             context,
326
             context,