Browse Source

rename content_type_slug and sub_content_type_slug

Guénaël Muller 6 years ago
parent
commit
5cf00321c9

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

@@ -64,10 +64,10 @@ class ContentCreation(object):
64 64
     def __init__(
65 65
             self,
66 66
             label: str,
67
-            content_type_slug: str,
67
+            content_type: str,
68 68
     ):
69 69
         self.label = label
70
-        self.content_type_slug = content_type_slug
70
+        self.content_type = content_type
71 71
 
72 72
 
73 73
 class UserInContext(object):
@@ -290,11 +290,11 @@ class ContentInContext(object):
290 290
         return self.content.label
291 291
 
292 292
     @property
293
-    def content_type_slug(self) -> str:
293
+    def content_type(self) -> str:
294 294
         return self.content.type
295 295
 
296 296
     @property
297
-    def sub_content_type_slug(self) -> typing.List[str]:
297
+    def sub_content_types(self) -> typing.List[str]:
298 298
         return [type.slug for type in self.content.get_allowed_content_types()]
299 299
 
300 300
     @property

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

@@ -247,7 +247,7 @@ class TestWorkspaceContents(FunctionalTest):
247 247
         assert content['show_in_ui'] is True
248 248
         assert content['slug'] == 'tools'
249 249
         assert content['status_slug'] == 'open'
250
-        assert set(content['sub_content_type_slug']) == {'thread', 'page', 'folder', 'file'}  # nopep8
250
+        assert set(content['sub_content_types']) == {'thread', 'page', 'folder', 'file'}  # nopep8
251 251
         assert content['workspace_id'] == 1
252 252
         content = res[1]
253 253
         assert content['id'] == 2
@@ -258,7 +258,7 @@ class TestWorkspaceContents(FunctionalTest):
258 258
         assert content['show_in_ui'] is True
259 259
         assert content['slug'] == 'menus'
260 260
         assert content['status_slug'] == 'open'
261
-        assert set(content['sub_content_type_slug']) == {'thread', 'page', 'folder', 'file'}  # nopep8
261
+        assert set(content['sub_content_types']) == {'thread', 'page', 'folder', 'file'}  # nopep8
262 262
         assert content['workspace_id'] == 1
263 263
         content = res[2]
264 264
         assert content['id'] == 11
@@ -269,7 +269,7 @@ class TestWorkspaceContents(FunctionalTest):
269 269
         assert content['show_in_ui'] is True
270 270
         assert content['slug'] == 'current-menu'
271 271
         assert content['status_slug'] == 'open'
272
-        assert set(content['sub_content_type_slug']) == {'thread', 'page', 'folder', 'file'}  # nopep8
272
+        assert set(content['sub_content_types']) == {'thread', 'page', 'folder', 'file'}  # nopep8
273 273
         assert content['workspace_id'] == 1
274 274
 
275 275
     # Root related
@@ -299,7 +299,7 @@ class TestWorkspaceContents(FunctionalTest):
299 299
         # TODO - G.M - 30-05-2018 - Check this test
300 300
         assert len(res) == 4
301 301
         content = res[1]
302
-        assert content['content_type_slug'] == 'page'
302
+        assert content['content_type'] == 'page'
303 303
         assert content['id'] == 15
304 304
         assert content['is_archived'] is False
305 305
         assert content['is_deleted'] is False
@@ -308,11 +308,11 @@ class TestWorkspaceContents(FunctionalTest):
308 308
         assert content['show_in_ui'] is True
309 309
         assert content['slug'] == 'new-fruit-salad'
310 310
         assert content['status_slug'] == 'open'
311
-        assert set(content['sub_content_type_slug']) == {'thread', 'page', 'folder', 'file'}  # nopep8
311
+        assert set(content['sub_content_types']) == {'thread', 'page', 'folder', 'file'}  # nopep8
312 312
         assert content['workspace_id'] == 3
313 313
 
314 314
         content = res[2]
315
-        assert content['content_type_slug'] == 'page'
315
+        assert content['content_type'] == 'page'
316 316
         assert content['id'] == 16
317 317
         assert content['is_archived'] is True
318 318
         assert content['is_deleted'] is False
@@ -321,11 +321,11 @@ class TestWorkspaceContents(FunctionalTest):
321 321
         assert content['show_in_ui'] is True
322 322
         assert content['slug'].startswith('fruit-salad')
323 323
         assert content['status_slug'] == 'open'
324
-        assert set(content['sub_content_type_slug']) == {'thread', 'page', 'folder', 'file'}  # nopep8
324
+        assert set(content['sub_content_types']) == {'thread', 'page', 'folder', 'file'}  # nopep8
325 325
         assert content['workspace_id'] == 3
326 326
 
327 327
         content = res[3]
328
-        assert content['content_type_slug'] == 'page'
328
+        assert content['content_type'] == 'page'
329 329
         assert content['id'] == 17
330 330
         assert content['is_archived'] is False
331 331
         assert content['is_deleted'] is True
@@ -334,7 +334,7 @@ class TestWorkspaceContents(FunctionalTest):
334 334
         assert content['show_in_ui'] is True
335 335
         assert content['slug'].startswith('bad-fruit-salad')
336 336
         assert content['status_slug'] == 'open'
337
-        assert set(content['sub_content_type_slug']) == {'thread', 'page', 'folder', 'file'}  # nopep8
337
+        assert set(content['sub_content_types']) == {'thread', 'page', 'folder', 'file'}  # nopep8
338 338
         assert content['workspace_id'] == 3
339 339
 
340 340
     def test_api__get_workspace_content__ok_200__get_only_active_root_content(self):  # nopep8
@@ -362,7 +362,7 @@ class TestWorkspaceContents(FunctionalTest):
362 362
         # TODO - G.M - 30-05-2018 - Check this test
363 363
         assert len(res) == 2
364 364
         content = res[1]
365
-        assert content['content_type_slug'] == 'page'
365
+        assert content['content_type'] == 'page'
366 366
         assert content['id'] == 15
367 367
         assert content['is_archived'] is False
368 368
         assert content['is_deleted'] is False
@@ -371,7 +371,7 @@ class TestWorkspaceContents(FunctionalTest):
371 371
         assert content['show_in_ui'] is True
372 372
         assert content['slug'] == 'new-fruit-salad'
373 373
         assert content['status_slug'] == 'open'
374
-        assert set(content['sub_content_type_slug']) == {'thread', 'page', 'folder', 'file'}  # nopep8
374
+        assert set(content['sub_content_types']) == {'thread', 'page', 'folder', 'file'}  # nopep8
375 375
         assert content['workspace_id'] == 3
376 376
 
377 377
     def test_api__get_workspace_content__ok_200__get_only_archived_root_content(self):  # nopep8
@@ -398,7 +398,7 @@ class TestWorkspaceContents(FunctionalTest):
398 398
         ).json_body   # nopep8
399 399
         assert len(res) == 1
400 400
         content = res[0]
401
-        assert content['content_type_slug'] == 'page'
401
+        assert content['content_type'] == 'page'
402 402
         assert content['id'] == 16
403 403
         assert content['is_archived'] is True
404 404
         assert content['is_deleted'] is False
@@ -407,7 +407,7 @@ class TestWorkspaceContents(FunctionalTest):
407 407
         assert content['show_in_ui'] is True
408 408
         assert content['slug'].startswith('fruit-salad')
409 409
         assert content['status_slug'] == 'open'
410
-        assert set(content['sub_content_type_slug']) == {'thread', 'page', 'folder', 'file'}  # nopep8
410
+        assert set(content['sub_content_types']) == {'thread', 'page', 'folder', 'file'}  # nopep8
411 411
         assert content['workspace_id'] == 3
412 412
 
413 413
     def test_api__get_workspace_content__ok_200__get_only_deleted_root_content(self):  # nopep8
@@ -436,7 +436,7 @@ class TestWorkspaceContents(FunctionalTest):
436 436
 
437 437
         assert len(res) == 1
438 438
         content = res[0]
439
-        assert content['content_type_slug'] == 'page'
439
+        assert content['content_type'] == 'page'
440 440
         assert content['id'] == 17
441 441
         assert content['is_archived'] is False
442 442
         assert content['is_deleted'] is True
@@ -445,7 +445,7 @@ class TestWorkspaceContents(FunctionalTest):
445 445
         assert content['show_in_ui'] is True
446 446
         assert content['slug'].startswith('bad-fruit-salad')
447 447
         assert content['status_slug'] == 'open'
448
-        assert set(content['sub_content_type_slug']) == {'thread', 'page', 'folder', 'file'}  # nopep8
448
+        assert set(content['sub_content_types']) == {'thread', 'page', 'folder', 'file'}  # nopep8
449 449
         assert content['workspace_id'] == 3
450 450
 
451 451
     def test_api__get_workspace_content__ok_200__get_nothing_root_content(self):
@@ -500,7 +500,7 @@ class TestWorkspaceContents(FunctionalTest):
500 500
         ).json_body   # nopep8
501 501
         assert len(res) == 3
502 502
         content = res[0]
503
-        assert content['content_type_slug'] == 'page'
503
+        assert content['content_type'] == 'page'
504 504
         assert content['id'] == 12
505 505
         assert content['is_archived'] is False
506 506
         assert content['is_deleted'] is False
@@ -509,11 +509,11 @@ class TestWorkspaceContents(FunctionalTest):
509 509
         assert content['show_in_ui'] is True
510 510
         assert content['slug'] == 'new-fruit-salad'
511 511
         assert content['status_slug'] == 'open'
512
-        assert set(content['sub_content_type_slug']) == {'thread', 'page', 'folder', 'file'}  # nopep8
512
+        assert set(content['sub_content_types']) == {'thread', 'page', 'folder', 'file'}  # nopep8
513 513
         assert content['workspace_id'] == 2
514 514
 
515 515
         content = res[1]
516
-        assert content['content_type_slug'] == 'page'
516
+        assert content['content_type'] == 'page'
517 517
         assert content['id'] == 13
518 518
         assert content['is_archived'] is True
519 519
         assert content['is_deleted'] is False
@@ -522,11 +522,11 @@ class TestWorkspaceContents(FunctionalTest):
522 522
         assert content['show_in_ui'] is True
523 523
         assert content['slug'].startswith('fruit-salad')
524 524
         assert content['status_slug'] == 'open'
525
-        assert set(content['sub_content_type_slug']) == {'thread', 'page', 'folder', 'file'}  # nopep8
525
+        assert set(content['sub_content_types']) == {'thread', 'page', 'folder', 'file'}  # nopep8
526 526
         assert content['workspace_id'] == 2
527 527
 
528 528
         content = res[2]
529
-        assert content['content_type_slug'] == 'page'
529
+        assert content['content_type'] == 'page'
530 530
         assert content['id'] == 14
531 531
         assert content['is_archived'] is False
532 532
         assert content['is_deleted'] is True
@@ -535,7 +535,7 @@ class TestWorkspaceContents(FunctionalTest):
535 535
         assert content['show_in_ui'] is True
536 536
         assert content['slug'].startswith('bad-fruit-salad')
537 537
         assert content['status_slug'] == 'open'
538
-        assert set(content['sub_content_type_slug']) == {'thread', 'page', 'folder', 'file'}  # nopep8
538
+        assert set(content['sub_content_types']) == {'thread', 'page', 'folder', 'file'}  # nopep8
539 539
         assert content['workspace_id'] == 2
540 540
 
541 541
     def test_api__get_workspace_content__ok_200__get_only_active_folder_content(self):  # nopep8
@@ -562,7 +562,7 @@ class TestWorkspaceContents(FunctionalTest):
562 562
         ).json_body   # nopep8
563 563
         assert len(res) == 1
564 564
         content = res[0]
565
-        assert content['content_type_slug']
565
+        assert content['content_type']
566 566
         assert content['id'] == 12
567 567
         assert content['is_archived'] is False
568 568
         assert content['is_deleted'] is False
@@ -571,7 +571,7 @@ class TestWorkspaceContents(FunctionalTest):
571 571
         assert content['show_in_ui'] is True
572 572
         assert content['slug'] == 'new-fruit-salad'
573 573
         assert content['status_slug'] == 'open'
574
-        assert set(content['sub_content_type_slug']) == {'thread', 'page', 'folder', 'file'}  # nopep8
574
+        assert set(content['sub_content_types']) == {'thread', 'page', 'folder', 'file'}  # nopep8
575 575
         assert content['workspace_id'] == 2
576 576
 
577 577
     def test_api__get_workspace_content__ok_200__get_only_archived_folder_content(self):  # nopep8
@@ -598,7 +598,7 @@ class TestWorkspaceContents(FunctionalTest):
598 598
         ).json_body   # nopep8
599 599
         assert len(res) == 1
600 600
         content = res[0]
601
-        assert content['content_type_slug'] == 'page'
601
+        assert content['content_type'] == 'page'
602 602
         assert content['id'] == 13
603 603
         assert content['is_archived'] is True
604 604
         assert content['is_deleted'] is False
@@ -607,7 +607,7 @@ class TestWorkspaceContents(FunctionalTest):
607 607
         assert content['show_in_ui'] is True
608 608
         assert content['slug'].startswith('fruit-salad')
609 609
         assert content['status_slug'] == 'open'
610
-        assert set(content['sub_content_type_slug']) == {'thread', 'page', 'folder', 'file'}  # nopep8
610
+        assert set(content['sub_content_types']) == {'thread', 'page', 'folder', 'file'}  # nopep8
611 611
         assert content['workspace_id'] == 2
612 612
 
613 613
     def test_api__get_workspace_content__ok_200__get_only_deleted_folder_content(self):  # nopep8
@@ -635,7 +635,7 @@ class TestWorkspaceContents(FunctionalTest):
635 635
 
636 636
         assert len(res) == 1
637 637
         content = res[0]
638
-        assert content['content_type_slug'] == 'page'
638
+        assert content['content_type'] == 'page'
639 639
         assert content['id'] == 14
640 640
         assert content['is_archived'] is False
641 641
         assert content['is_deleted'] is True
@@ -644,7 +644,7 @@ class TestWorkspaceContents(FunctionalTest):
644 644
         assert content['show_in_ui'] is True
645 645
         assert content['slug'].startswith('bad-fruit-salad')
646 646
         assert content['status_slug'] == 'open'
647
-        assert set(content['sub_content_type_slug']) == {'thread', 'page', 'folder', 'file'}  # nopep8
647
+        assert set(content['sub_content_types']) == {'thread', 'page', 'folder', 'file'}  # nopep8
648 648
         assert content['workspace_id'] == 2
649 649
 
650 650
     def test_api__get_workspace_content__ok_200__get_nothing_folder_content(self):  # nopep8
@@ -741,7 +741,7 @@ class TestWorkspaceContents(FunctionalTest):
741 741
         )
742 742
         params = {
743 743
             'label': 'GenericCreatedContent',
744
-            'content_type_slug': 'markdownpage',
744
+            'content_type': 'markdownpage',
745 745
         }
746 746
         res = self.testapp.post_json(
747 747
             '/api/v2/workspaces/1/contents',
@@ -752,14 +752,14 @@ class TestWorkspaceContents(FunctionalTest):
752 752
         assert res.json_body
753 753
         assert res.json_body['status_slug'] == 'open'
754 754
         assert res.json_body['id']
755
-        assert res.json_body['content_type_slug'] == 'markdownpage'
755
+        assert res.json_body['content_type'] == 'markdownpage'
756 756
         assert res.json_body['is_archived'] is False
757 757
         assert res.json_body['is_deleted'] is False
758 758
         assert res.json_body['workspace_id'] == 1
759 759
         assert res.json_body['slug'] == 'genericcreatedcontent'
760 760
         assert res.json_body['parent_id'] is None
761 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 763
         params_active = {
764 764
             'parent_id': 0,
765 765
             'show_archived': 0,

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

@@ -311,7 +311,7 @@ class ContentCreationSchema(marshmallow.Schema):
311 311
         example='contract for client XXX',
312 312
         description='Title of the content to create'
313 313
     )
314
-    content_type_slug = marshmallow.fields.String(
314
+    content_type = marshmallow.fields.String(
315 315
         example='htmlpage',
316 316
         validate=OneOf([content.slug for content in CONTENT_DEFAULT_TYPE]),
317 317
     )
@@ -333,11 +333,11 @@ class ContentDigestSchema(marshmallow.Schema):
333 333
         example=19,
334 334
     )
335 335
     label = marshmallow.fields.Str(example='Intervention Report 12')
336
-    content_type_slug = marshmallow.fields.Str(
336
+    content_type = marshmallow.fields.Str(
337 337
         example='htmlpage',
338 338
         validate=OneOf([content.slug for content in CONTENT_DEFAULT_TYPE]),
339 339
     )
340
-    sub_content_type_slug = marshmallow.fields.List(
340
+    sub_content_types = marshmallow.fields.List(
341 341
         marshmallow.fields.Str,
342 342
         description='list of content types allowed as sub contents. '
343 343
                     'This field is required for folder contents, '

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

@@ -145,7 +145,7 @@ class WorkspaceController(Controller):
145 145
         )
146 146
         content = api.create(
147 147
             label=creation_data.label,
148
-            content_type=creation_data.content_type_slug,
148
+            content_type=creation_data.content_type,
149 149
             workspace=request.current_workspace,
150 150
         )
151 151
         api.save(content, ActionDescription.CREATION)