Browse Source

Merge pull request #9 from tracim/fix/better_app_content_type_list

Bastien Sevajol 5 years ago
parent
commit
6f902b63e4
No account linked to committer's email

+ 14 - 2
backend/tracim_backend/models/applications.py View File

@@ -59,6 +59,16 @@ thread = Application(
59 59
 
60 60
 )
61 61
 
62
+folder = Application(
63
+    label='Folder',
64
+    slug='contents/folder',
65
+    fa_icon='folder-open-o',
66
+    hexcolor='#252525',
67
+    is_active=True,
68
+    config={},
69
+    main_route='',
70
+)
71
+
62 72
 _file = Application(
63 73
     label='Files',
64 74
     slug='contents/file',
@@ -92,8 +102,10 @@ html_documents = Application(
92 102
 # List of applications
93 103
 applications = [
94 104
     html_documents,
95
-    markdownpluspage,
105
+    # TODO - G.M - 2018-08-02 - Restore markdownpage app
106
+    # markdownpluspage,
96 107
     _file,
97 108
     thread,
98
-    calendar,
109
+    folder,
110
+    # calendar,
99 111
 ]

+ 6 - 4
backend/tracim_backend/models/contents.py View File

@@ -6,6 +6,7 @@ from tracim_backend.exceptions import ContentTypeNotExist
6 6
 from tracim_backend.exceptions import ContentStatusNotExist
7 7
 from tracim_backend.models.applications import html_documents
8 8
 from tracim_backend.models.applications import _file
9
+from tracim_backend.models.applications import folder
9 10
 from tracim_backend.models.applications import thread
10 11
 from tracim_backend.models.applications import markdownpluspage
11 12
 
@@ -171,10 +172,10 @@ html_documents_type = ContentType(
171 172
 # TODO - G.M - 31-05-2018 - Set Better folder params
172 173
 folder_type = ContentType(
173 174
     slug='folder',
174
-    fa_icon=thread.fa_icon,
175
-    hexcolor=thread.hexcolor,
175
+    fa_icon=folder.fa_icon,
176
+    hexcolor=folder.hexcolor,
176 177
     label='Folder',
177
-    creation_label='Create collection of any documents',
178
+    creation_label='Create a folder',
178 179
     available_statuses=CONTENT_STATUS.get_all(),
179 180
 )
180 181
 
@@ -261,7 +262,8 @@ CONTENT_TYPES = ContentTypeList(
261 262
     [
262 263
         thread_type,
263 264
         file_type,
264
-        markdownpluspage_type,
265
+        # TODO - G.M - 2018-08-02 - Restore markdown page content
266
+        #    markdownpluspage_type,
265 267
         html_documents_type,
266 268
     ]
267 269
 )

+ 24 - 72
backend/tracim_backend/tests/functional/test_system.py View File

@@ -1,5 +1,7 @@
1 1
 # coding=utf-8
2
+from tracim_backend.models.contents import CONTENT_TYPES
2 3
 from tracim_backend.tests import FunctionalTest
4
+from tracim_backend.models.applications import applications
3 5
 
4 6
 """
5 7
 Tests for /api/v2/system subpath endpoints.
@@ -24,41 +26,14 @@ class TestApplicationEndpoint(FunctionalTest):
24 26
         )
25 27
         res = self.testapp.get('/api/v2/system/applications', status=200)
26 28
         res = res.json_body
27
-        application = res[0]
28
-        assert application['label'] == "Text Documents"
29
-        assert application['slug'] == 'contents/html-document'
30
-        assert application['fa_icon'] == 'file-text-o'
31
-        assert application['hexcolor'] == '#3f52e3'
32
-        assert application['is_active'] is True
33
-        assert 'config' in application
34
-        application = res[1]
35
-        assert application['label'] == "Markdown Plus Documents"
36
-        assert application['slug'] == 'contents/markdownpluspage'
37
-        assert application['fa_icon'] == 'file-code-o'
38
-        assert application['hexcolor'] == '#f12d2d'
39
-        assert application['is_active'] is True
40
-        assert 'config' in application
41
-        application = res[2]
42
-        assert application['label'] == "Files"
43
-        assert application['slug'] == 'contents/file'
44
-        assert application['fa_icon'] == 'paperclip'
45
-        assert application['hexcolor'] == '#FF9900'
46
-        assert application['is_active'] is True
47
-        assert 'config' in application
48
-        application = res[3]
49
-        assert application['label'] == "Threads"
50
-        assert application['slug'] == 'contents/thread'
51
-        assert application['fa_icon'] == 'comments-o'
52
-        assert application['hexcolor'] == '#ad4cf9'
53
-        assert application['is_active'] is True
54
-        assert 'config' in application
55
-        application = res[4]
56
-        assert application['label'] == "Calendar"
57
-        assert application['slug'] == 'calendar'
58
-        assert application['fa_icon'] == 'calendar'
59
-        assert application['hexcolor'] == '#757575'
60
-        assert application['is_active'] is True
61
-        assert 'config' in application
29
+        assert len(res) == len(applications)
30
+        for counter, application in enumerate(applications):
31
+            assert res[counter]['label'] == application.label
32
+            assert res[counter]['slug'] == application.slug
33
+            assert res[counter]['fa_icon'] == application.fa_icon
34
+            assert res[counter]['hexcolor'] == application.hexcolor
35
+            assert res[counter]['is_active'] == application.is_active
36
+            assert res[counter]['config'] == application.config
62 37
 
63 38
     def test_api__get_applications__err_401__unregistered_user(self):
64 39
         """
@@ -96,44 +71,21 @@ class TestContentsTypesEndpoint(FunctionalTest):
96 71
         )
97 72
         res = self.testapp.get('/api/v2/system/content_types', status=200)
98 73
         res = res.json_body
74
+        assert len(res) == len(CONTENT_TYPES.endpoint_allowed_types_slug())
75
+        content_types = CONTENT_TYPES.endpoint_allowed_types_slug()
99 76
 
100
-        content_type = res[1]
101
-        assert content_type['slug'] == 'thread'
102
-        assert content_type['fa_icon'] == 'comments-o'
103
-        assert content_type['hexcolor'] == '#ad4cf9'
104
-        assert content_type['label'] == 'Thread'
105
-        assert content_type['creation_label'] == 'Discuss about a topic'
106
-        assert 'available_statuses' in content_type
107
-        assert len(content_type['available_statuses']) == 4
108
-
109
-        content_type = res[2]
110
-        assert content_type['slug'] == 'file'
111
-        assert content_type['fa_icon'] == 'paperclip'
112
-        assert content_type['hexcolor'] == '#FF9900'
113
-        assert content_type['label'] == 'File'
114
-        assert content_type['creation_label'] == 'Upload a file'
115
-        assert 'available_statuses' in content_type
116
-        assert len(content_type['available_statuses']) == 4
117
-
118
-        content_type = res[3]
119
-        assert content_type['slug'] == 'markdownpage'
120
-        assert content_type['fa_icon'] == 'file-code-o'
121
-        assert content_type['hexcolor'] == '#f12d2d'
122
-        assert content_type['label'] == 'Rich Markdown File'
123
-        assert content_type['creation_label'] == 'Create a Markdown document'
124
-        assert 'available_statuses' in content_type
125
-        assert len(content_type['available_statuses']) == 4
126
-
127
-        content_type = res[4]
128
-        assert content_type['slug'] == 'html-document'
129
-        assert content_type['fa_icon'] == 'file-text-o'
130
-        assert content_type['hexcolor'] == '#3f52e3'
131
-        assert content_type['label'] == 'Text Document'
132
-        assert content_type['creation_label'] == 'Write a document'
133
-        assert 'available_statuses' in content_type
134
-        assert len(content_type['available_statuses']) == 4
135
-        # TODO - G.M - 31-05-2018 - Check Folder type
136
-        # TODO - G.M - 29-05-2018 - Better check for available_statuses
77
+        for counter, content_type_slug in enumerate(content_types):
78
+            content_type = CONTENT_TYPES.get_one_by_slug(content_type_slug)
79
+            assert res[counter]['slug'] == content_type.slug
80
+            assert res[counter]['fa_icon'] == content_type.fa_icon
81
+            assert res[counter]['hexcolor'] == content_type.hexcolor
82
+            assert res[counter]['label'] == content_type.label
83
+            assert res[counter]['creation_label'] == content_type.creation_label
84
+            for status_counter, status in enumerate(content_type.available_statuses):
85
+                assert res[counter]['available_statuses'][status_counter]['fa_icon'] == status.fa_icon  # nopep8
86
+                assert res[counter]['available_statuses'][status_counter]['global_status'] == status.global_status  # nopep8
87
+                assert res[counter]['available_statuses'][status_counter]['slug'] == status.slug  # nopep8
88
+                assert res[counter]['available_statuses'][status_counter]['hexcolor'] == status.hexcolor  # nopep8
137 89
 
138 90
     def test_api__get_content_types__err_401__unregistered_user(self):
139 91
         """

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

@@ -2382,8 +2382,10 @@ class TestUserWorkspaceEndpoint(FunctionalTest):
2382 2382
         assert workspace['workspace_id'] == 1
2383 2383
         assert workspace['label'] == 'Business'
2384 2384
         assert workspace['slug'] == 'business'
2385
-        assert len(workspace['sidebar_entries']) == 7
2385
+        assert len(workspace['sidebar_entries']) == 5
2386 2386
 
2387
+        # TODO - G.M - 2018-08-02 - Better test for sidebar entry, make it
2388
+        # not fixed on active application/content-file
2387 2389
         sidebar_entry = workspace['sidebar_entries'][0]
2388 2390
         assert sidebar_entry['slug'] == 'dashboard'
2389 2391
         assert sidebar_entry['label'] == 'Dashboard'
@@ -2406,32 +2408,19 @@ class TestUserWorkspaceEndpoint(FunctionalTest):
2406 2408
         assert sidebar_entry['fa_icon'] == "file-text-o"
2407 2409
 
2408 2410
         sidebar_entry = workspace['sidebar_entries'][3]
2409
-        assert sidebar_entry['slug'] == 'contents/markdownpluspage'
2410
-        assert sidebar_entry['label'] == 'Markdown Plus Documents'
2411
-        assert sidebar_entry['route'] == "/#/workspaces/1/contents?type=markdownpluspage"    # nopep8
2412
-        assert sidebar_entry['hexcolor'] == "#f12d2d"
2413
-        assert sidebar_entry['fa_icon'] == "file-code-o"
2414
-
2415
-        sidebar_entry = workspace['sidebar_entries'][4]
2416 2411
         assert sidebar_entry['slug'] == 'contents/file'
2417 2412
         assert sidebar_entry['label'] == 'Files'
2418 2413
         assert sidebar_entry['route'] == "/#/workspaces/1/contents?type=file"  # nopep8
2419 2414
         assert sidebar_entry['hexcolor'] == "#FF9900"
2420 2415
         assert sidebar_entry['fa_icon'] == "paperclip"
2421 2416
 
2422
-        sidebar_entry = workspace['sidebar_entries'][5]
2417
+        sidebar_entry = workspace['sidebar_entries'][4]
2423 2418
         assert sidebar_entry['slug'] == 'contents/thread'
2424 2419
         assert sidebar_entry['label'] == 'Threads'
2425 2420
         assert sidebar_entry['route'] == "/#/workspaces/1/contents?type=thread"  # nopep8
2426 2421
         assert sidebar_entry['hexcolor'] == "#ad4cf9"
2427 2422
         assert sidebar_entry['fa_icon'] == "comments-o"
2428 2423
 
2429
-        sidebar_entry = workspace['sidebar_entries'][6]
2430
-        assert sidebar_entry['slug'] == 'calendar'
2431
-        assert sidebar_entry['label'] == 'Calendar'
2432
-        assert sidebar_entry['route'] == "/#/workspaces/1/calendar"  # nopep8
2433
-        assert sidebar_entry['hexcolor'] == "#757575"
2434
-        assert sidebar_entry['fa_icon'] == "calendar"
2435 2424
 
2436 2425
     def test_api__get_user_workspaces__err_403__unallowed_user(self):
2437 2426
         """

+ 14 - 26
backend/tracim_backend/tests/functional/test_workspaces.py View File

@@ -41,8 +41,10 @@ class TestWorkspaceEndpoint(FunctionalTest):
41 41
         assert workspace['slug'] == 'business'
42 42
         assert workspace['label'] == 'Business'
43 43
         assert workspace['description'] == 'All importants documents'
44
-        assert len(workspace['sidebar_entries']) == 7
44
+        assert len(workspace['sidebar_entries']) == 5
45 45
 
46
+        # TODO - G.M - 2018-08-02 - Better test for sidebar entry, make it
47
+        # not fixed on active application/content-file
46 48
         sidebar_entry = workspace['sidebar_entries'][0]
47 49
         assert sidebar_entry['slug'] == 'dashboard'
48 50
         assert sidebar_entry['label'] == 'Dashboard'
@@ -65,33 +67,19 @@ class TestWorkspaceEndpoint(FunctionalTest):
65 67
         assert sidebar_entry['fa_icon'] == "file-text-o"
66 68
 
67 69
         sidebar_entry = workspace['sidebar_entries'][3]
68
-        assert sidebar_entry['slug'] == 'contents/markdownpluspage'
69
-        assert sidebar_entry['label'] == 'Markdown Plus Documents'
70
-        assert sidebar_entry['route'] == "/#/workspaces/1/contents?type=markdownpluspage"    # nopep8
71
-        assert sidebar_entry['hexcolor'] == "#f12d2d"
72
-        assert sidebar_entry['fa_icon'] == "file-code-o"
73
-
74
-        sidebar_entry = workspace['sidebar_entries'][4]
75 70
         assert sidebar_entry['slug'] == 'contents/file'
76 71
         assert sidebar_entry['label'] == 'Files'
77 72
         assert sidebar_entry['route'] == "/#/workspaces/1/contents?type=file"  # nopep8
78 73
         assert sidebar_entry['hexcolor'] == "#FF9900"
79 74
         assert sidebar_entry['fa_icon'] == "paperclip"
80 75
 
81
-        sidebar_entry = workspace['sidebar_entries'][5]
76
+        sidebar_entry = workspace['sidebar_entries'][4]
82 77
         assert sidebar_entry['slug'] == 'contents/thread'
83 78
         assert sidebar_entry['label'] == 'Threads'
84 79
         assert sidebar_entry['route'] == "/#/workspaces/1/contents?type=thread"  # nopep8
85 80
         assert sidebar_entry['hexcolor'] == "#ad4cf9"
86 81
         assert sidebar_entry['fa_icon'] == "comments-o"
87 82
 
88
-        sidebar_entry = workspace['sidebar_entries'][6]
89
-        assert sidebar_entry['slug'] == 'calendar'
90
-        assert sidebar_entry['label'] == 'Calendar'
91
-        assert sidebar_entry['route'] == "/#/workspaces/1/calendar"  # nopep8
92
-        assert sidebar_entry['hexcolor'] == "#757575"
93
-        assert sidebar_entry['fa_icon'] == "calendar"
94
-
95 83
     def test_api__update_workspace__ok_200__nominal_case(self) -> None:
96 84
         """
97 85
         Test update workspace
@@ -118,7 +106,7 @@ class TestWorkspaceEndpoint(FunctionalTest):
118 106
         assert workspace['slug'] == 'business'
119 107
         assert workspace['label'] == 'Business'
120 108
         assert workspace['description'] == 'All importants documents'
121
-        assert len(workspace['sidebar_entries']) == 7
109
+        assert len(workspace['sidebar_entries']) == 5
122 110
 
123 111
         # modify workspace
124 112
         res = self.testapp.put_json(
@@ -132,7 +120,7 @@ class TestWorkspaceEndpoint(FunctionalTest):
132 120
         assert workspace['slug'] == 'superworkspace'
133 121
         assert workspace['label'] == 'superworkspace'
134 122
         assert workspace['description'] == 'mysuperdescription'
135
-        assert len(workspace['sidebar_entries']) == 7
123
+        assert len(workspace['sidebar_entries']) == 5
136 124
 
137 125
         # after
138 126
         res = self.testapp.get(
@@ -145,7 +133,7 @@ class TestWorkspaceEndpoint(FunctionalTest):
145 133
         assert workspace['slug'] == 'superworkspace'
146 134
         assert workspace['label'] == 'superworkspace'
147 135
         assert workspace['description'] == 'mysuperdescription'
148
-        assert len(workspace['sidebar_entries']) == 7
136
+        assert len(workspace['sidebar_entries']) == 5
149 137
 
150 138
     def test_api__update_workspace__err_400__empty_label(self) -> None:
151 139
         """
@@ -1438,7 +1426,7 @@ class TestWorkspaceContents(FunctionalTest):
1438 1426
         params = {
1439 1427
             'parent_id': None,
1440 1428
             'label': 'GenericCreatedContent',
1441
-            'content_type': 'markdownpage',
1429
+            'content_type': 'html-document',
1442 1430
         }
1443 1431
         res = self.testapp.post_json(
1444 1432
             '/api/v2/workspaces/1/contents',
@@ -1449,7 +1437,7 @@ class TestWorkspaceContents(FunctionalTest):
1449 1437
         assert res.json_body
1450 1438
         assert res.json_body['status'] == 'open'
1451 1439
         assert res.json_body['content_id']
1452
-        assert res.json_body['content_type'] == 'markdownpage'
1440
+        assert res.json_body['content_type'] == 'html-document'
1453 1441
         assert res.json_body['is_archived'] is False
1454 1442
         assert res.json_body['is_deleted'] is False
1455 1443
         assert res.json_body['workspace_id'] == 1
@@ -1480,7 +1468,7 @@ class TestWorkspaceContents(FunctionalTest):
1480 1468
         )
1481 1469
         params = {
1482 1470
             'label': 'GenericCreatedContent',
1483
-            'content_type': 'markdownpage',
1471
+            'content_type': 'html-document',
1484 1472
         }
1485 1473
         res = self.testapp.post_json(
1486 1474
             '/api/v2/workspaces/1/contents',
@@ -1491,7 +1479,7 @@ class TestWorkspaceContents(FunctionalTest):
1491 1479
         assert res.json_body
1492 1480
         assert res.json_body['status'] == 'open'
1493 1481
         assert res.json_body['content_id']
1494
-        assert res.json_body['content_type'] == 'markdownpage'
1482
+        assert res.json_body['content_type'] == 'html-document'
1495 1483
         assert res.json_body['is_archived'] is False
1496 1484
         assert res.json_body['is_deleted'] is False
1497 1485
         assert res.json_body['workspace_id'] == 1
@@ -1544,7 +1532,7 @@ class TestWorkspaceContents(FunctionalTest):
1544 1532
         )
1545 1533
         params = {
1546 1534
             'label': 'GenericCreatedContent',
1547
-            'content_type': 'markdownpage',
1535
+            'content_type': 'html-document',
1548 1536
             'parent_id': 10,
1549 1537
         }
1550 1538
         res = self.testapp.post_json(
@@ -1556,7 +1544,7 @@ class TestWorkspaceContents(FunctionalTest):
1556 1544
         assert res.json_body
1557 1545
         assert res.json_body['status'] == 'open'
1558 1546
         assert res.json_body['content_id']
1559
-        assert res.json_body['content_type'] == 'markdownpage'
1547
+        assert res.json_body['content_type'] == 'html-document'
1560 1548
         assert res.json_body['is_archived'] is False
1561 1549
         assert res.json_body['is_deleted'] is False
1562 1550
         assert res.json_body['workspace_id'] == 1
@@ -1587,7 +1575,7 @@ class TestWorkspaceContents(FunctionalTest):
1587 1575
         )
1588 1576
         params = {
1589 1577
             'label': '',
1590
-            'content_type': 'markdownpage',
1578
+            'content_type': 'html-document',
1591 1579
         }
1592 1580
         res = self.testapp.post_json(
1593 1581
             '/api/v2/workspaces/1/contents',