Browse Source

Merge branch 'feature/578_add_api_for_workspace/apps' of github.com:tracim/tracim_backend into fix/better_api_doc

Guénaël Muller 6 years ago
parent
commit
1522357032

+ 2 - 2
tracim/lib/webdav/design.py View File

@@ -164,7 +164,7 @@ def designPage(content: data.Content, content_revision: data.ContentRevisionRO)
164 164
                     <td>%s</td>
165 165
                 </tr>
166 166
                 ''' % ('warning' if event.id == content_revision.revision_id else '',
167
-                       event.type.icon,
167
+                       event.type.fa_icon,
168 168
                        label,
169 169
                        date,
170 170
                        event.owner.display_name,
@@ -282,7 +282,7 @@ def designThread(content: data.Content, content_revision: data.ContentRevisionRO
282 282
                         </div>
283 283
                     </div>
284 284
                     ''' % ('warning' if t.id == content_revision.revision_id else '',
285
-                           t.type.icon,
285
+                           t.type.fa_icon,
286 286
                            t.owner.display_name,
287 287
                            t.create_readable_date(),
288 288
                            label,

+ 19 - 7
tracim/models/applications.py View File

@@ -10,15 +10,27 @@ class Application(object):
10 10
             self,
11 11
             label: str,
12 12
             slug: str,
13
-            icon: str,
13
+            fa_icon: str,
14 14
             hexcolor: str,
15 15
             is_active: bool,
16 16
             config: typing.Dict[str, str],
17 17
             main_route: str,
18 18
     ) -> None:
19
+        """
20
+        @param label: public label of application
21
+        @param slug: identifier of application
22
+        @param icon: font awesome icon class
23
+        @param hexcolor: hexa color of application main color
24
+        @param is_active: True if application enable, False if inactive
25
+        @param config: a dict with eventual application config
26
+        @param main_route: the route of the frontend "home" screen of
27
+        the application. For exemple, if you have an application
28
+        called "calendar", the main route will be something
29
+        like /#/workspace/{wid}/calendar.
30
+        """
19 31
         self.label = label
20 32
         self.slug = slug
21
-        self.icon = icon
33
+        self.fa_icon = fa_icon
22 34
         self.hexcolor = hexcolor
23 35
         self.is_active = is_active
24 36
         self.config = config
@@ -29,7 +41,7 @@ class Application(object):
29 41
 calendar = Application(
30 42
     label='Calendar',
31 43
     slug='calendar',
32
-    icon='calendar-alt',
44
+    fa_icon='calendar-alt',
33 45
     hexcolor='#757575',
34 46
     is_active=True,
35 47
     config={},
@@ -39,7 +51,7 @@ calendar = Application(
39 51
 thread = Application(
40 52
     label='Threads',
41 53
     slug='contents/threads',
42
-    icon='comments-o',
54
+    fa_icon='comments-o',
43 55
     hexcolor='#ad4cf9',
44 56
     is_active=True,
45 57
     config={},
@@ -50,7 +62,7 @@ thread = Application(
50 62
 _file = Application(
51 63
     label='Files',
52 64
     slug='contents/files',
53
-    icon='paperclip',
65
+    fa_icon='paperclip',
54 66
     hexcolor='#FF9900',
55 67
     is_active=True,
56 68
     config={},
@@ -60,7 +72,7 @@ _file = Application(
60 72
 markdownpluspage = Application(
61 73
     label='Markdown Plus Documents',  # TODO - G.M - 24-05-2018 - Check label
62 74
     slug='contents/markdownpluspage',
63
-    icon='file-code',
75
+    fa_icon='file-code',
64 76
     hexcolor='#f12d2d',
65 77
     is_active=True,
66 78
     config={},
@@ -70,7 +82,7 @@ markdownpluspage = Application(
70 82
 htmlpage = Application(
71 83
     label='Text Documents',  # TODO - G.M - 24-05-2018 - Check label
72 84
     slug='contents/htmlpage',
73
-    icon='file-text-o',
85
+    fa_icon='file-text-o',
74 86
     hexcolor='#3f52e3',
75 87
     is_active=True,
76 88
     config={},

+ 9 - 8
tracim/models/data.py View File

@@ -162,7 +162,7 @@ class UserRoleInWorkspace(DeclarativeBase):
162 162
     #
163 163
     #
164 164
     # @property
165
-    # def icon(self):
165
+    # def fa_icon(self):
166 166
     #     return UserRoleInWorkspace.ICON[self.role]
167 167
     #
168 168
     # @property
@@ -200,7 +200,7 @@ class RoleType(object):
200 200
     def __init__(self, role_id):
201 201
         self.role_type_id = role_id
202 202
         # TODO - G.M - 10-04-2018 - [Cleanup] Drop this
203
-        # self.icon = UserRoleInWorkspace.ICON[role_id]
203
+        # self.fa_icon = UserRoleInWorkspace.ICON[role_id]
204 204
         # self.role_label = UserRoleInWorkspace.LABEL[role_id]
205 205
         # self.css_style = UserRoleInWorkspace.STYLE[role_id]
206 206
 
@@ -265,11 +265,12 @@ class ActionDescription(object):
265 265
     def __init__(self, id):
266 266
         assert id in ActionDescription.allowed_values()
267 267
         self.id = id
268
-        # FIXME - G.M - 17-04-2018 - Label and icon needed for webdav
268
+        # FIXME - G.M - 17-04-2018 - Label and fa_icon needed for webdav
269 269
         #  design template,
270 270
         # find a way to not rely on this.
271 271
         self.label = self.id
272
-        self.icon = ActionDescription._ICONS[id]
272
+        self.fa_icon = ActionDescription._ICONS[id]
273
+        #self.icon = self.fa_icon
273 274
         # TODO - G.M - 10-04-2018 - [Cleanup] Drop this
274 275
         # self.label = ActionDescription._LABELS[id]
275 276
 
@@ -343,7 +344,7 @@ class ContentStatus(object):
343 344
         self.id = id
344 345
         self.label = self.id
345 346
         # TODO - G.M - 10-04-2018 - [Cleanup] Drop this
346
-        # self.icon = ContentStatus._ICONS[id]
347
+        # self.fa_icon = ContentStatus._ICONS[id]
347 348
         # self.css = ContentStatus._CSS[id]
348 349
         #
349 350
         # if type==ContentType.Thread:
@@ -520,7 +521,7 @@ class ContentType(object):
520 521
     def __init__(self, type):
521 522
         self.id = type
522 523
         # TODO - G.M - 10-04-2018 - [Cleanup] Drop this
523
-        # self.icon = ContentType._CSS_ICONS[type]
524
+        # self.fa_icon = ContentType._CSS_ICONS[type]
524 525
         # self.color = ContentType._CSS_COLORS[type]  # deprecated
525 526
         # self.css = ContentType._CSS_COLORS[type]
526 527
         # self.label = ContentType._LABEL[type]
@@ -530,7 +531,7 @@ class ContentType(object):
530 531
         return dict(id=self.type,
531 532
                     type=self.type,
532 533
                     # TODO - G.M - 10-04-2018 - [Cleanup] Drop this
533
-                    # icon=self.icon,
534
+                    # fa_icon=self.fa_icon,
534 535
                     # color=self.color,
535 536
                     # label=self.label,
536 537
                     priority=self.priority)
@@ -1457,7 +1458,7 @@ class VirtualEvent(object):
1457 1458
         assert hasattr(type, 'id')
1458 1459
         # TODO - G.M - 10-04-2018 - [Cleanup] Drop this
1459 1460
         # assert hasattr(type, 'css')
1460
-        # assert hasattr(type, 'icon')
1461
+        # assert hasattr(type, 'fa_icon')
1461 1462
         # assert hasattr(type, 'label')
1462 1463
 
1463 1464
     def created_as_delta(self, delta_from_datetime:datetime=None):

+ 5 - 5
tracim/models/workspace_menu_entries.py View File

@@ -14,7 +14,7 @@ class WorkspaceMenuEntry(object):
14 14
             self,
15 15
             label: str,
16 16
             slug: str,
17
-            icon: str,
17
+            fa_icon: str,
18 18
             hexcolor: str,
19 19
             route: str,
20 20
     ) -> None:
@@ -22,21 +22,21 @@ class WorkspaceMenuEntry(object):
22 22
         self.label = label
23 23
         self.route = route
24 24
         self.hexcolor = hexcolor
25
-        self.icon = icon
25
+        self.fa_icon = fa_icon
26 26
 
27 27
 dashboard_menu_entry = WorkspaceMenuEntry(
28 28
   slug='dashboard',
29 29
   label='Dashboard',
30 30
   route='/#/workspaces/{workspace_id}/dashboard',
31 31
   hexcolor='#252525',
32
-  icon="",
32
+  fa_icon="",
33 33
 )
34 34
 all_content_menu_entry = WorkspaceMenuEntry(
35 35
   slug="contents/all",
36 36
   label="All Contents",
37 37
   route="/#/workspaces/{workspace_id}/contents",
38 38
   hexcolor="#fdfdfd",
39
-  icon="",
39
+  fa_icon="",
40 40
 )
41 41
 
42 42
 # TODO - G.M - 08-06-2018 - This is hardcoded default menu entry,
@@ -57,7 +57,7 @@ def default_workspace_menu_entry(
57 57
                 slug=app.slug,
58 58
                 label=app.label,
59 59
                 hexcolor=app.hexcolor,
60
-                icon=app.icon,
60
+                fa_icon=app.fa_icon,
61 61
                 route=app.main_route
62 62
             )
63 63
             menu_entries.append(new_entry)

+ 5 - 5
tracim/tests/functional/test_system.py View File

@@ -26,35 +26,35 @@ class TestApplicationsEndpoint(FunctionalTest):
26 26
         application = res[0]
27 27
         assert application['label'] == "Text Documents"
28 28
         assert application['slug'] == 'contents/htmlpage'
29
-        assert application['icon'] == 'file-text-o'
29
+        assert application['fa_icon'] == 'file-text-o'
30 30
         assert application['hexcolor'] == '#3f52e3'
31 31
         assert application['is_active'] is True
32 32
         assert 'config' in application
33 33
         application = res[1]
34 34
         assert application['label'] == "Markdown Plus Documents"
35 35
         assert application['slug'] == 'contents/markdownpluspage'
36
-        assert application['icon'] == 'file-code'
36
+        assert application['fa_icon'] == 'file-code'
37 37
         assert application['hexcolor'] == '#f12d2d'
38 38
         assert application['is_active'] is True
39 39
         assert 'config' in application
40 40
         application = res[2]
41 41
         assert application['label'] == "Files"
42 42
         assert application['slug'] == 'contents/files'
43
-        assert application['icon'] == 'paperclip'
43
+        assert application['fa_icon'] == 'paperclip'
44 44
         assert application['hexcolor'] == '#FF9900'
45 45
         assert application['is_active'] is True
46 46
         assert 'config' in application
47 47
         application = res[3]
48 48
         assert application['label'] == "Threads"
49 49
         assert application['slug'] == 'contents/threads'
50
-        assert application['icon'] == 'comments-o'
50
+        assert application['fa_icon'] == 'comments-o'
51 51
         assert application['hexcolor'] == '#ad4cf9'
52 52
         assert application['is_active'] is True
53 53
         assert 'config' in application
54 54
         application = res[4]
55 55
         assert application['label'] == "Calendar"
56 56
         assert application['slug'] == 'calendar'
57
-        assert application['icon'] == 'calendar-alt'
57
+        assert application['fa_icon'] == 'calendar-alt'
58 58
         assert application['hexcolor'] == '#757575'
59 59
         assert application['is_active'] is True
60 60
         assert 'config' in application

+ 7 - 7
tracim/tests/functional/test_user.py View File

@@ -37,49 +37,49 @@ class TestUserWorkspaceEndpoint(FunctionalTest):
37 37
         assert sidebar_entry['label'] == 'Dashboard'
38 38
         assert sidebar_entry['route'] == '/#/workspaces/1/dashboard'  # nopep8
39 39
         assert sidebar_entry['hexcolor'] == "#252525"
40
-        assert sidebar_entry['icon'] == ""
40
+        assert sidebar_entry['fa_icon'] == ""
41 41
 
42 42
         sidebar_entry = workspace['sidebar_entries'][1]
43 43
         assert sidebar_entry['slug'] == 'contents/all'
44 44
         assert sidebar_entry['label'] == 'All Contents'
45 45
         assert sidebar_entry['route'] == "/#/workspaces/1/contents"  # nopep8
46 46
         assert sidebar_entry['hexcolor'] == "#fdfdfd"
47
-        assert sidebar_entry['icon'] == ""
47
+        assert sidebar_entry['fa_icon'] == ""
48 48
 
49 49
         sidebar_entry = workspace['sidebar_entries'][2]
50 50
         assert sidebar_entry['slug'] == 'contents/htmlpage'
51 51
         assert sidebar_entry['label'] == 'Text Documents'
52 52
         assert sidebar_entry['route'] == '/#/workspaces/1/contents?type=htmlpage'  # nopep8
53 53
         assert sidebar_entry['hexcolor'] == "#3f52e3"
54
-        assert sidebar_entry['icon'] == "file-text-o"
54
+        assert sidebar_entry['fa_icon'] == "file-text-o"
55 55
 
56 56
         sidebar_entry = workspace['sidebar_entries'][3]
57 57
         assert sidebar_entry['slug'] == 'contents/markdownpluspage'
58 58
         assert sidebar_entry['label'] == 'Markdown Plus Documents'
59 59
         assert sidebar_entry['route'] == "/#/workspaces/1/contents?type=markdownpluspage"    # nopep8
60 60
         assert sidebar_entry['hexcolor'] == "#f12d2d"
61
-        assert sidebar_entry['icon'] == "file-code"
61
+        assert sidebar_entry['fa_icon'] == "file-code"
62 62
 
63 63
         sidebar_entry = workspace['sidebar_entries'][4]
64 64
         assert sidebar_entry['slug'] == 'contents/files'
65 65
         assert sidebar_entry['label'] == 'Files'
66 66
         assert sidebar_entry['route'] == "/#/workspaces/1/contents?type=file"  # nopep8
67 67
         assert sidebar_entry['hexcolor'] == "#FF9900"
68
-        assert sidebar_entry['icon'] == "paperclip"
68
+        assert sidebar_entry['fa_icon'] == "paperclip"
69 69
 
70 70
         sidebar_entry = workspace['sidebar_entries'][5]
71 71
         assert sidebar_entry['slug'] == 'contents/threads'
72 72
         assert sidebar_entry['label'] == 'Threads'
73 73
         assert sidebar_entry['route'] == "/#/workspaces/1/contents?type=thread"  # nopep8
74 74
         assert sidebar_entry['hexcolor'] == "#ad4cf9"
75
-        assert sidebar_entry['icon'] == "comments-o"
75
+        assert sidebar_entry['fa_icon'] == "comments-o"
76 76
 
77 77
         sidebar_entry = workspace['sidebar_entries'][6]
78 78
         assert sidebar_entry['slug'] == 'calendar'
79 79
         assert sidebar_entry['label'] == 'Calendar'
80 80
         assert sidebar_entry['route'] == "/#/workspaces/1/calendar"  # nopep8
81 81
         assert sidebar_entry['hexcolor'] == "#757575"
82
-        assert sidebar_entry['icon'] == "calendar-alt"
82
+        assert sidebar_entry['fa_icon'] == "calendar-alt"
83 83
 
84 84
     def test_api__get_user_workspaces__err_403__unallowed_user(self):
85 85
         """

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

@@ -38,49 +38,49 @@ class TestWorkspaceEndpoint(FunctionalTest):
38 38
         assert sidebar_entry['label'] == 'Dashboard'
39 39
         assert sidebar_entry['route'] == '/#/workspaces/1/dashboard'  # nopep8
40 40
         assert sidebar_entry['hexcolor'] == "#252525"
41
-        assert sidebar_entry['icon'] == ""
41
+        assert sidebar_entry['fa_icon'] == ""
42 42
 
43 43
         sidebar_entry = workspace['sidebar_entries'][1]
44 44
         assert sidebar_entry['slug'] == 'contents/all'
45 45
         assert sidebar_entry['label'] == 'All Contents'
46 46
         assert sidebar_entry['route'] == "/#/workspaces/1/contents"  # nopep8
47 47
         assert sidebar_entry['hexcolor'] == "#fdfdfd"
48
-        assert sidebar_entry['icon'] == ""
48
+        assert sidebar_entry['fa_icon'] == ""
49 49
 
50 50
         sidebar_entry = workspace['sidebar_entries'][2]
51 51
         assert sidebar_entry['slug'] == 'contents/htmlpage'
52 52
         assert sidebar_entry['label'] == 'Text Documents'
53 53
         assert sidebar_entry['route'] == '/#/workspaces/1/contents?type=htmlpage'  # nopep8
54 54
         assert sidebar_entry['hexcolor'] == "#3f52e3"
55
-        assert sidebar_entry['icon'] == "file-text-o"
55
+        assert sidebar_entry['fa_icon'] == "file-text-o"
56 56
 
57 57
         sidebar_entry = workspace['sidebar_entries'][3]
58 58
         assert sidebar_entry['slug'] == 'contents/markdownpluspage'
59 59
         assert sidebar_entry['label'] == 'Markdown Plus Documents'
60 60
         assert sidebar_entry['route'] == "/#/workspaces/1/contents?type=markdownpluspage"    # nopep8
61 61
         assert sidebar_entry['hexcolor'] == "#f12d2d"
62
-        assert sidebar_entry['icon'] == "file-code"
62
+        assert sidebar_entry['fa_icon'] == "file-code"
63 63
 
64 64
         sidebar_entry = workspace['sidebar_entries'][4]
65 65
         assert sidebar_entry['slug'] == 'contents/files'
66 66
         assert sidebar_entry['label'] == 'Files'
67 67
         assert sidebar_entry['route'] == "/#/workspaces/1/contents?type=file"  # nopep8
68 68
         assert sidebar_entry['hexcolor'] == "#FF9900"
69
-        assert sidebar_entry['icon'] == "paperclip"
69
+        assert sidebar_entry['fa_icon'] == "paperclip"
70 70
 
71 71
         sidebar_entry = workspace['sidebar_entries'][5]
72 72
         assert sidebar_entry['slug'] == 'contents/threads'
73 73
         assert sidebar_entry['label'] == 'Threads'
74 74
         assert sidebar_entry['route'] == "/#/workspaces/1/contents?type=thread"  # nopep8
75 75
         assert sidebar_entry['hexcolor'] == "#ad4cf9"
76
-        assert sidebar_entry['icon'] == "comments-o"
76
+        assert sidebar_entry['fa_icon'] == "comments-o"
77 77
 
78 78
         sidebar_entry = workspace['sidebar_entries'][6]
79 79
         assert sidebar_entry['slug'] == 'calendar'
80 80
         assert sidebar_entry['label'] == 'Calendar'
81 81
         assert sidebar_entry['route'] == "/#/workspaces/1/calendar"  # nopep8
82 82
         assert sidebar_entry['hexcolor'] == "#757575"
83
-        assert sidebar_entry['icon'] == "calendar-alt"
83
+        assert sidebar_entry['fa_icon'] == "calendar-alt"
84 84
 
85 85
     def test_api__get_workspace__err_403__unallowed_user(self) -> None:
86 86
         """

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

@@ -114,7 +114,7 @@ class WorkspaceMenuEntrySchema(marshmallow.Schema):
114 114
                     'which must be replaced on backend size '
115 115
                     '(the route must be ready-to-use)'
116 116
     )
117
-    icon = marshmallow.fields.String(
117
+    fa_icon = marshmallow.fields.String(
118 118
         example='file-text-o',
119 119
         description='CSS class of the icon. Example: file-o for using Fontawesome file-text-o icon',  # nopep8
120 120
     )
@@ -170,7 +170,7 @@ class ApplicationConfigSchema(marshmallow.Schema):
170 170
 class ApplicationSchema(marshmallow.Schema):
171 171
     label = marshmallow.fields.String(example='Calendar')
172 172
     slug = marshmallow.fields.String(example='calendar')
173
-    icon = marshmallow.fields.String(
173
+    fa_icon = marshmallow.fields.String(
174 174
         example='file-o',
175 175
         description='CSS class of the icon. Example: file-o for using Fontawesome file-o icon',  # nopep8
176 176
     )