Browse Source

rename endpoints swagger tags constants

Guénaël Muller 6 years ago
parent
commit
8c9feae41e

+ 4 - 4
backend/tracim_backend/views/contents_api/comment_controller.py View File

24
 from tracim_backend.models.revision_protection import new_revision
24
 from tracim_backend.models.revision_protection import new_revision
25
 from tracim_backend.models.data import UserRoleInWorkspace
25
 from tracim_backend.models.data import UserRoleInWorkspace
26
 
26
 
27
-COMMENT_ENDPOINTS_TAG = 'Comments'
27
+SWAGGER_TAG__COMMENT_ENDPOINTS = 'Comments'
28
 
28
 
29
 
29
 
30
 class CommentController(Controller):
30
 class CommentController(Controller):
31
 
31
 
32
-    @hapic.with_api_doc(tags=[COMMENT_ENDPOINTS_TAG])
32
+    @hapic.with_api_doc(tags=[SWAGGER_TAG__COMMENT_ENDPOINTS])
33
     @require_workspace_role(UserRoleInWorkspace.READER)
33
     @require_workspace_role(UserRoleInWorkspace.READER)
34
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
34
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
35
     @hapic.output_body(CommentSchema(many=True))
35
     @hapic.output_body(CommentSchema(many=True))
55
                 for comment in comments
55
                 for comment in comments
56
         ]
56
         ]
57
 
57
 
58
-    @hapic.with_api_doc(tags=[COMMENT_ENDPOINTS_TAG])
58
+    @hapic.with_api_doc(tags=[SWAGGER_TAG__COMMENT_ENDPOINTS])
59
     @hapic.handle_exception(EmptyCommentContentNotAllowed, HTTPStatus.BAD_REQUEST)  # nopep8
59
     @hapic.handle_exception(EmptyCommentContentNotAllowed, HTTPStatus.BAD_REQUEST)  # nopep8
60
     @require_workspace_role(UserRoleInWorkspace.CONTRIBUTOR)
60
     @require_workspace_role(UserRoleInWorkspace.CONTRIBUTOR)
61
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
61
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
84
         )
84
         )
85
         return api.get_content_in_context(comment)
85
         return api.get_content_in_context(comment)
86
 
86
 
87
-    @hapic.with_api_doc(tags=[COMMENT_ENDPOINTS_TAG])
87
+    @hapic.with_api_doc(tags=[SWAGGER_TAG__COMMENT_ENDPOINTS])
88
     @require_comment_ownership_or_role(
88
     @require_comment_ownership_or_role(
89
         minimal_required_role_for_anyone=UserRoleInWorkspace.WORKSPACE_MANAGER,
89
         minimal_required_role_for_anyone=UserRoleInWorkspace.WORKSPACE_MANAGER,
90
         minimal_required_role_for_owner=UserRoleInWorkspace.CONTRIBUTOR,
90
         minimal_required_role_for_owner=UserRoleInWorkspace.CONTRIBUTOR,

+ 15 - 15
backend/tracim_backend/views/contents_api/file_controller.py View File

39
 from tracim_backend.exceptions import PageOfPreviewNotFound
39
 from tracim_backend.exceptions import PageOfPreviewNotFound
40
 from tracim_backend.exceptions import PreviewDimNotAllowed
40
 from tracim_backend.exceptions import PreviewDimNotAllowed
41
 
41
 
42
-FILE_ENDPOINTS_TAG = 'Files'
42
+SWAGGER_TAG__FILE_ENDPOINTS = 'Files'
43
 
43
 
44
 
44
 
45
 class FileController(Controller):
45
 class FileController(Controller):
48
     """
48
     """
49
 
49
 
50
     # File data
50
     # File data
51
-    @hapic.with_api_doc(tags=[FILE_ENDPOINTS_TAG])
51
+    @hapic.with_api_doc(tags=[SWAGGER_TAG__FILE_ENDPOINTS])
52
     @require_workspace_role(UserRoleInWorkspace.CONTRIBUTOR)
52
     @require_workspace_role(UserRoleInWorkspace.CONTRIBUTOR)
53
     @require_content_types([file_type])
53
     @require_content_types([file_type])
54
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
54
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
84
 
84
 
85
         return
85
         return
86
 
86
 
87
-    @hapic.with_api_doc(tags=[FILE_ENDPOINTS_TAG])
87
+    @hapic.with_api_doc(tags=[SWAGGER_TAG__FILE_ENDPOINTS])
88
     @require_workspace_role(UserRoleInWorkspace.READER)
88
     @require_workspace_role(UserRoleInWorkspace.READER)
89
     @require_content_types([file_type])
89
     @require_content_types([file_type])
90
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
90
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
109
         response.app_iter = FileIter(file)
109
         response.app_iter = FileIter(file)
110
         return response
110
         return response
111
 
111
 
112
-    @hapic.with_api_doc(tags=[FILE_ENDPOINTS_TAG])
112
+    @hapic.with_api_doc(tags=[SWAGGER_TAG__FILE_ENDPOINTS])
113
     @require_workspace_role(UserRoleInWorkspace.READER)
113
     @require_workspace_role(UserRoleInWorkspace.READER)
114
     @require_content_types([file_type])
114
     @require_content_types([file_type])
115
     @hapic.input_path(WorkspaceAndContentRevisionIdPathSchema())
115
     @hapic.input_path(WorkspaceAndContentRevisionIdPathSchema())
140
 
140
 
141
     # preview
141
     # preview
142
     # pdf
142
     # pdf
143
-    @hapic.with_api_doc(tags=[FILE_ENDPOINTS_TAG])
143
+    @hapic.with_api_doc(tags=[SWAGGER_TAG__FILE_ENDPOINTS])
144
     @require_workspace_role(UserRoleInWorkspace.READER)
144
     @require_workspace_role(UserRoleInWorkspace.READER)
145
     @require_content_types([file_type])
145
     @require_content_types([file_type])
146
     @hapic.handle_exception(UnavailablePreviewType, HTTPStatus.BAD_REQUEST)
146
     @hapic.handle_exception(UnavailablePreviewType, HTTPStatus.BAD_REQUEST)
169
         )
169
         )
170
         return FileResponse(pdf_preview_path)
170
         return FileResponse(pdf_preview_path)
171
 
171
 
172
-    @hapic.with_api_doc(tags=[FILE_ENDPOINTS_TAG])
172
+    @hapic.with_api_doc(tags=[SWAGGER_TAG__FILE_ENDPOINTS])
173
     @require_workspace_role(UserRoleInWorkspace.READER)
173
     @require_workspace_role(UserRoleInWorkspace.READER)
174
     @require_content_types([file_type])
174
     @require_content_types([file_type])
175
     @hapic.handle_exception(UnavailablePreviewType, HTTPStatus.BAD_REQUEST)
175
     @hapic.handle_exception(UnavailablePreviewType, HTTPStatus.BAD_REQUEST)
192
         pdf_preview_path = api.get_full_pdf_preview_path(content.revision_id)
192
         pdf_preview_path = api.get_full_pdf_preview_path(content.revision_id)
193
         return FileResponse(pdf_preview_path)
193
         return FileResponse(pdf_preview_path)
194
 
194
 
195
-    @hapic.with_api_doc(tags=[FILE_ENDPOINTS_TAG])
195
+    @hapic.with_api_doc(tags=[SWAGGER_TAG__FILE_ENDPOINTS])
196
     @require_workspace_role(UserRoleInWorkspace.READER)
196
     @require_workspace_role(UserRoleInWorkspace.READER)
197
     @require_content_types([file_type])
197
     @require_content_types([file_type])
198
     @hapic.handle_exception(UnavailablePreviewType, HTTPStatus.BAD_REQUEST)
198
     @hapic.handle_exception(UnavailablePreviewType, HTTPStatus.BAD_REQUEST)
225
         return FileResponse(pdf_preview_path)
225
         return FileResponse(pdf_preview_path)
226
 
226
 
227
     # jpg
227
     # jpg
228
-    @hapic.with_api_doc(tags=[FILE_ENDPOINTS_TAG])
228
+    @hapic.with_api_doc(tags=[SWAGGER_TAG__FILE_ENDPOINTS])
229
     @require_workspace_role(UserRoleInWorkspace.READER)
229
     @require_workspace_role(UserRoleInWorkspace.READER)
230
     @require_content_types([file_type])
230
     @require_content_types([file_type])
231
     @hapic.handle_exception(PageOfPreviewNotFound, HTTPStatus.BAD_REQUEST)
231
     @hapic.handle_exception(PageOfPreviewNotFound, HTTPStatus.BAD_REQUEST)
256
         )
256
         )
257
         return FileResponse(jpg_preview_path)
257
         return FileResponse(jpg_preview_path)
258
 
258
 
259
-    @hapic.with_api_doc(tags=[FILE_ENDPOINTS_TAG])
259
+    @hapic.with_api_doc(tags=[SWAGGER_TAG__FILE_ENDPOINTS])
260
     @require_workspace_role(UserRoleInWorkspace.READER)
260
     @require_workspace_role(UserRoleInWorkspace.READER)
261
     @require_content_types([file_type])
261
     @require_content_types([file_type])
262
     @hapic.handle_exception(PageOfPreviewNotFound, HTTPStatus.BAD_REQUEST)
262
     @hapic.handle_exception(PageOfPreviewNotFound, HTTPStatus.BAD_REQUEST)
287
         )
287
         )
288
         return FileResponse(jpg_preview_path)
288
         return FileResponse(jpg_preview_path)
289
 
289
 
290
-    @hapic.with_api_doc(tags=[FILE_ENDPOINTS_TAG])
290
+    @hapic.with_api_doc(tags=[SWAGGER_TAG__FILE_ENDPOINTS])
291
     @require_workspace_role(UserRoleInWorkspace.READER)
291
     @require_workspace_role(UserRoleInWorkspace.READER)
292
     @require_content_types([file_type])
292
     @require_content_types([file_type])
293
     @hapic.handle_exception(PageOfPreviewNotFound, HTTPStatus.BAD_REQUEST)
293
     @hapic.handle_exception(PageOfPreviewNotFound, HTTPStatus.BAD_REQUEST)
322
         )
322
         )
323
         return FileResponse(jpg_preview_path)
323
         return FileResponse(jpg_preview_path)
324
 
324
 
325
-    @hapic.with_api_doc(tags=[FILE_ENDPOINTS_TAG])
325
+    @hapic.with_api_doc(tags=[SWAGGER_TAG__FILE_ENDPOINTS])
326
     @require_workspace_role(UserRoleInWorkspace.READER)
326
     @require_workspace_role(UserRoleInWorkspace.READER)
327
     @require_content_types([file_type])
327
     @require_content_types([file_type])
328
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
328
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
341
         return api.get_jpg_preview_allowed_dim()
341
         return api.get_jpg_preview_allowed_dim()
342
 
342
 
343
     # File infos
343
     # File infos
344
-    @hapic.with_api_doc(tags=[FILE_ENDPOINTS_TAG])
344
+    @hapic.with_api_doc(tags=[SWAGGER_TAG__FILE_ENDPOINTS])
345
     @require_workspace_role(UserRoleInWorkspace.READER)
345
     @require_workspace_role(UserRoleInWorkspace.READER)
346
     @require_content_types([file_type])
346
     @require_content_types([file_type])
347
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
347
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
362
         )
362
         )
363
         return api.get_content_in_context(content)
363
         return api.get_content_in_context(content)
364
 
364
 
365
-    @hapic.with_api_doc(tags=[FILE_ENDPOINTS_TAG])
365
+    @hapic.with_api_doc(tags=[SWAGGER_TAG__FILE_ENDPOINTS])
366
     @hapic.handle_exception(EmptyLabelNotAllowed, HTTPStatus.BAD_REQUEST)
366
     @hapic.handle_exception(EmptyLabelNotAllowed, HTTPStatus.BAD_REQUEST)
367
     @require_workspace_role(UserRoleInWorkspace.CONTRIBUTOR)
367
     @require_workspace_role(UserRoleInWorkspace.CONTRIBUTOR)
368
     @require_content_types([file_type])
368
     @require_content_types([file_type])
397
             api.save(content)
397
             api.save(content)
398
         return api.get_content_in_context(content)
398
         return api.get_content_in_context(content)
399
 
399
 
400
-    @hapic.with_api_doc(tags=[FILE_ENDPOINTS_TAG])
400
+    @hapic.with_api_doc(tags=[SWAGGER_TAG__FILE_ENDPOINTS])
401
     @require_workspace_role(UserRoleInWorkspace.READER)
401
     @require_workspace_role(UserRoleInWorkspace.READER)
402
     @require_content_types([file_type])
402
     @require_content_types([file_type])
403
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
403
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
427
             for revision in revisions
427
             for revision in revisions
428
         ]
428
         ]
429
 
429
 
430
-    @hapic.with_api_doc(tags=[FILE_ENDPOINTS_TAG])
430
+    @hapic.with_api_doc(tags=[SWAGGER_TAG__FILE_ENDPOINTS])
431
     @hapic.handle_exception(EmptyLabelNotAllowed, HTTPStatus.BAD_REQUEST)
431
     @hapic.handle_exception(EmptyLabelNotAllowed, HTTPStatus.BAD_REQUEST)
432
     @require_workspace_role(UserRoleInWorkspace.CONTRIBUTOR)
432
     @require_workspace_role(UserRoleInWorkspace.CONTRIBUTOR)
433
     @require_content_types([file_type])
433
     @require_content_types([file_type])

+ 5 - 5
backend/tracim_backend/views/contents_api/html_document_controller.py View File

30
 from tracim_backend.models.contents import html_documents_type
30
 from tracim_backend.models.contents import html_documents_type
31
 from tracim_backend.models.revision_protection import new_revision
31
 from tracim_backend.models.revision_protection import new_revision
32
 
32
 
33
-HTML_DOCUMENT_ENDPOINTS_TAG = 'HTML documents'
33
+SWAGGER_TAG__HTML_DOCUMENT_ENDPOINTS = 'HTML documents'
34
 
34
 
35
 
35
 
36
 class HTMLDocumentController(Controller):
36
 class HTMLDocumentController(Controller):
37
 
37
 
38
-    @hapic.with_api_doc(tags=[HTML_DOCUMENT_ENDPOINTS_TAG])
38
+    @hapic.with_api_doc(tags=[SWAGGER_TAG__HTML_DOCUMENT_ENDPOINTS])
39
     @require_workspace_role(UserRoleInWorkspace.READER)
39
     @require_workspace_role(UserRoleInWorkspace.READER)
40
     @require_content_types([html_documents_type])
40
     @require_content_types([html_documents_type])
41
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
41
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
56
         )
56
         )
57
         return api.get_content_in_context(content)
57
         return api.get_content_in_context(content)
58
 
58
 
59
-    @hapic.with_api_doc(tags=[HTML_DOCUMENT_ENDPOINTS_TAG])
59
+    @hapic.with_api_doc(tags=[SWAGGER_TAG__HTML_DOCUMENT_ENDPOINTS])
60
     @hapic.handle_exception(EmptyLabelNotAllowed, HTTPStatus.BAD_REQUEST)
60
     @hapic.handle_exception(EmptyLabelNotAllowed, HTTPStatus.BAD_REQUEST)
61
     @require_workspace_role(UserRoleInWorkspace.CONTRIBUTOR)
61
     @require_workspace_role(UserRoleInWorkspace.CONTRIBUTOR)
62
     @require_content_types([html_documents_type])
62
     @require_content_types([html_documents_type])
91
             api.save(content)
91
             api.save(content)
92
         return api.get_content_in_context(content)
92
         return api.get_content_in_context(content)
93
 
93
 
94
-    @hapic.with_api_doc(tags=[HTML_DOCUMENT_ENDPOINTS_TAG])
94
+    @hapic.with_api_doc(tags=[SWAGGER_TAG__HTML_DOCUMENT_ENDPOINTS])
95
     @require_workspace_role(UserRoleInWorkspace.READER)
95
     @require_workspace_role(UserRoleInWorkspace.READER)
96
     @require_content_types([html_documents_type])
96
     @require_content_types([html_documents_type])
97
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
97
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
121
             for revision in revisions
121
             for revision in revisions
122
         ]
122
         ]
123
 
123
 
124
-    @hapic.with_api_doc(tags=[HTML_DOCUMENT_ENDPOINTS_TAG])
124
+    @hapic.with_api_doc(tags=[SWAGGER_TAG__HTML_DOCUMENT_ENDPOINTS])
125
     @require_workspace_role(UserRoleInWorkspace.CONTRIBUTOR)
125
     @require_workspace_role(UserRoleInWorkspace.CONTRIBUTOR)
126
     @require_content_types([html_documents_type])
126
     @require_content_types([html_documents_type])
127
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
127
     @hapic.input_path(WorkspaceAndContentIdPathSchema())

+ 5 - 5
backend/tracim_backend/views/contents_api/threads_controller.py View File

29
 from tracim_backend.models.contents import thread_type
29
 from tracim_backend.models.contents import thread_type
30
 from tracim_backend.models.revision_protection import new_revision
30
 from tracim_backend.models.revision_protection import new_revision
31
 
31
 
32
-THREAD_ENDPOINTS_TAG = 'Threads'
32
+SWAGGER_TAG__THREAD_ENDPOINTS = 'Threads'
33
 
33
 
34
 
34
 
35
 class ThreadController(Controller):
35
 class ThreadController(Controller):
36
 
36
 
37
-    @hapic.with_api_doc(tags=[THREAD_ENDPOINTS_TAG])
37
+    @hapic.with_api_doc(tags=[SWAGGER_TAG__THREAD_ENDPOINTS])
38
     @require_workspace_role(UserRoleInWorkspace.READER)
38
     @require_workspace_role(UserRoleInWorkspace.READER)
39
     @require_content_types([thread_type])
39
     @require_content_types([thread_type])
40
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
40
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
55
         )
55
         )
56
         return api.get_content_in_context(content)
56
         return api.get_content_in_context(content)
57
 
57
 
58
-    @hapic.with_api_doc(tags=[THREAD_ENDPOINTS_TAG])
58
+    @hapic.with_api_doc(tags=[SWAGGER_TAG__THREAD_ENDPOINTS])
59
     @hapic.handle_exception(EmptyLabelNotAllowed, HTTPStatus.BAD_REQUEST)
59
     @hapic.handle_exception(EmptyLabelNotAllowed, HTTPStatus.BAD_REQUEST)
60
     @require_workspace_role(UserRoleInWorkspace.CONTRIBUTOR)
60
     @require_workspace_role(UserRoleInWorkspace.CONTRIBUTOR)
61
     @require_content_types([thread_type])
61
     @require_content_types([thread_type])
90
             api.save(content)
90
             api.save(content)
91
         return api.get_content_in_context(content)
91
         return api.get_content_in_context(content)
92
 
92
 
93
-    @hapic.with_api_doc(tags=[THREAD_ENDPOINTS_TAG])
93
+    @hapic.with_api_doc(tags=[SWAGGER_TAG__THREAD_ENDPOINTS])
94
     @require_workspace_role(UserRoleInWorkspace.READER)
94
     @require_workspace_role(UserRoleInWorkspace.READER)
95
     @require_content_types([thread_type])
95
     @require_content_types([thread_type])
96
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
96
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
120
             for revision in revisions
120
             for revision in revisions
121
         ]
121
         ]
122
 
122
 
123
-    @hapic.with_api_doc(tags=[THREAD_ENDPOINTS_TAG])
123
+    @hapic.with_api_doc(tags=[SWAGGER_TAG__THREAD_ENDPOINTS])
124
     @require_workspace_role(UserRoleInWorkspace.CONTRIBUTOR)
124
     @require_workspace_role(UserRoleInWorkspace.CONTRIBUTOR)
125
     @require_content_types([thread_type])
125
     @require_content_types([thread_type])
126
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
126
     @hapic.input_path(WorkspaceAndContentIdPathSchema())

+ 4 - 4
backend/tracim_backend/views/core_api/session_controller.py View File

16
 from tracim_backend.exceptions import NotAuthenticated
16
 from tracim_backend.exceptions import NotAuthenticated
17
 from tracim_backend.exceptions import AuthenticationFailed
17
 from tracim_backend.exceptions import AuthenticationFailed
18
 
18
 
19
-SESSION_ENDPOINTS_TAG = 'Session'
19
+SWAGGER_TAG__SESSION_ENDPOINTS = 'Session'
20
 
20
 
21
 
21
 
22
 class SessionController(Controller):
22
 class SessionController(Controller):
23
 
23
 
24
-    @hapic.with_api_doc(tags=[SESSION_ENDPOINTS_TAG])
24
+    @hapic.with_api_doc(tags=[SWAGGER_TAG__SESSION_ENDPOINTS])
25
     @hapic.input_headers(LoginOutputHeaders())
25
     @hapic.input_headers(LoginOutputHeaders())
26
     @hapic.input_body(BasicAuthSchema())
26
     @hapic.input_body(BasicAuthSchema())
27
     # TODO - G.M - 17-04-2018 - fix output header ?
27
     # TODO - G.M - 17-04-2018 - fix output header ?
42
         user = uapi.authenticate_user(login.email, login.password)
42
         user = uapi.authenticate_user(login.email, login.password)
43
         return uapi.get_user_with_context(user)
43
         return uapi.get_user_with_context(user)
44
 
44
 
45
-    @hapic.with_api_doc(tags=[SESSION_ENDPOINTS_TAG])
45
+    @hapic.with_api_doc(tags=[SWAGGER_TAG__SESSION_ENDPOINTS])
46
     @hapic.output_body(NoContentSchema(), default_http_code=HTTPStatus.NO_CONTENT)  # nopep8
46
     @hapic.output_body(NoContentSchema(), default_http_code=HTTPStatus.NO_CONTENT)  # nopep8
47
     def logout(self, context, request: TracimRequest, hapic_data=None):
47
     def logout(self, context, request: TracimRequest, hapic_data=None):
48
         """
48
         """
51
 
51
 
52
         return
52
         return
53
 
53
 
54
-    @hapic.with_api_doc(tags=[SESSION_ENDPOINTS_TAG])
54
+    @hapic.with_api_doc(tags=[SWAGGER_TAG__SESSION_ENDPOINTS])
55
     @hapic.output_body(UserSchema(),)
55
     @hapic.output_body(UserSchema(),)
56
     def whoami(self, context, request: TracimRequest, hapic_data=None):
56
     def whoami(self, context, request: TracimRequest, hapic_data=None):
57
         """
57
         """

+ 3 - 3
backend/tracim_backend/views/core_api/system_controller.py View File

18
 from tracim_backend.views.core_api.schemas import ApplicationSchema
18
 from tracim_backend.views.core_api.schemas import ApplicationSchema
19
 from tracim_backend.views.core_api.schemas import ContentTypeSchema
19
 from tracim_backend.views.core_api.schemas import ContentTypeSchema
20
 
20
 
21
-SYSTEM_ENDPOINTS_TAG = 'System'
21
+SWAGGER_TAG_SYSTEM_ENDPOINTS = 'System'
22
 
22
 
23
 
23
 
24
 class SystemController(Controller):
24
 class SystemController(Controller):
25
 
25
 
26
-    @hapic.with_api_doc(tags=[SYSTEM_ENDPOINTS_TAG])
26
+    @hapic.with_api_doc(tags=[SWAGGER_TAG_SYSTEM_ENDPOINTS])
27
     @require_profile(Group.TIM_USER)
27
     @require_profile(Group.TIM_USER)
28
     @hapic.output_body(ApplicationSchema(many=True),)
28
     @hapic.output_body(ApplicationSchema(many=True),)
29
     def applications(self, context, request: TracimRequest, hapic_data=None):
29
     def applications(self, context, request: TracimRequest, hapic_data=None):
32
         """
32
         """
33
         return applications
33
         return applications
34
 
34
 
35
-    @hapic.with_api_doc(tags=[SYSTEM_ENDPOINTS_TAG])
35
+    @hapic.with_api_doc(tags=[SWAGGER_TAG_SYSTEM_ENDPOINTS])
36
     @require_profile(Group.TIM_USER)
36
     @require_profile(Group.TIM_USER)
37
     @hapic.output_body(ContentTypeSchema(many=True),)
37
     @hapic.output_body(ContentTypeSchema(many=True),)
38
     def content_types(self, context, request: TracimRequest, hapic_data=None):
38
     def content_types(self, context, request: TracimRequest, hapic_data=None):

+ 15 - 15
backend/tracim_backend/views/core_api/user_controller.py View File

32
 from tracim_backend.views.core_api.schemas import ActiveContentFilterQuerySchema
32
 from tracim_backend.views.core_api.schemas import ActiveContentFilterQuerySchema
33
 from tracim_backend.views.core_api.schemas import WorkspaceDigestSchema
33
 from tracim_backend.views.core_api.schemas import WorkspaceDigestSchema
34
 
34
 
35
-USER_ENDPOINTS_TAG = 'Users'
35
+SWAGGER_TAG__USER_ENDPOINTS = 'Users'
36
 
36
 
37
 
37
 
38
 class UserController(Controller):
38
 class UserController(Controller):
39
 
39
 
40
-    @hapic.with_api_doc(tags=[USER_ENDPOINTS_TAG])
40
+    @hapic.with_api_doc(tags=[SWAGGER_TAG__USER_ENDPOINTS])
41
     @require_same_user_or_profile(Group.TIM_ADMIN)
41
     @require_same_user_or_profile(Group.TIM_ADMIN)
42
     @hapic.input_path(UserIdPathSchema())
42
     @hapic.input_path(UserIdPathSchema())
43
     @hapic.output_body(WorkspaceDigestSchema(many=True),)
43
     @hapic.output_body(WorkspaceDigestSchema(many=True),)
58
             for workspace in workspaces
58
             for workspace in workspaces
59
         ]
59
         ]
60
 
60
 
61
-    @hapic.with_api_doc(tags=[USER_ENDPOINTS_TAG])
61
+    @hapic.with_api_doc(tags=[SWAGGER_TAG__USER_ENDPOINTS])
62
     @require_same_user_or_profile(Group.TIM_ADMIN)
62
     @require_same_user_or_profile(Group.TIM_ADMIN)
63
     @hapic.input_path(UserIdPathSchema())
63
     @hapic.input_path(UserIdPathSchema())
64
     @hapic.output_body(UserSchema())
64
     @hapic.output_body(UserSchema())
74
         )
74
         )
75
         return uapi.get_user_with_context(request.candidate_user)
75
         return uapi.get_user_with_context(request.candidate_user)
76
 
76
 
77
-    @hapic.with_api_doc(tags=[USER_ENDPOINTS_TAG])
77
+    @hapic.with_api_doc(tags=[SWAGGER_TAG__USER_ENDPOINTS])
78
     @hapic.handle_exception(WrongUserPassword, HTTPStatus.FORBIDDEN)
78
     @hapic.handle_exception(WrongUserPassword, HTTPStatus.FORBIDDEN)
79
     @require_same_user_or_profile(Group.TIM_ADMIN)
79
     @require_same_user_or_profile(Group.TIM_ADMIN)
80
     @hapic.input_body(SetEmailSchema())
80
     @hapic.input_body(SetEmailSchema())
98
         )
98
         )
99
         return uapi.get_user_with_context(user)
99
         return uapi.get_user_with_context(user)
100
 
100
 
101
-    @hapic.with_api_doc(tags=[USER_ENDPOINTS_TAG])
101
+    @hapic.with_api_doc(tags=[SWAGGER_TAG__USER_ENDPOINTS])
102
     @hapic.handle_exception(WrongUserPassword, HTTPStatus.FORBIDDEN)
102
     @hapic.handle_exception(WrongUserPassword, HTTPStatus.FORBIDDEN)
103
     @hapic.handle_exception(PasswordDoNotMatch, HTTPStatus.BAD_REQUEST)
103
     @hapic.handle_exception(PasswordDoNotMatch, HTTPStatus.BAD_REQUEST)
104
     @require_same_user_or_profile(Group.TIM_ADMIN)
104
     @require_same_user_or_profile(Group.TIM_ADMIN)
124
         )
124
         )
125
         return
125
         return
126
 
126
 
127
-    @hapic.with_api_doc(tags=[USER_ENDPOINTS_TAG])
127
+    @hapic.with_api_doc(tags=[SWAGGER_TAG__USER_ENDPOINTS])
128
     @require_same_user_or_profile(Group.TIM_ADMIN)
128
     @require_same_user_or_profile(Group.TIM_ADMIN)
129
     @hapic.input_body(UserInfosSchema())
129
     @hapic.input_body(UserInfosSchema())
130
     @hapic.input_path(UserIdPathSchema())
130
     @hapic.input_path(UserIdPathSchema())
147
         )
147
         )
148
         return uapi.get_user_with_context(user)
148
         return uapi.get_user_with_context(user)
149
 
149
 
150
-    @hapic.with_api_doc(tags=[USER_ENDPOINTS_TAG])
150
+    @hapic.with_api_doc(tags=[SWAGGER_TAG__USER_ENDPOINTS])
151
     @require_profile(Group.TIM_ADMIN)
151
     @require_profile(Group.TIM_ADMIN)
152
     @hapic.input_path(UserIdPathSchema())
152
     @hapic.input_path(UserIdPathSchema())
153
     @hapic.input_body(UserCreationSchema())
153
     @hapic.input_body(UserCreationSchema())
179
         )
179
         )
180
         return uapi.get_user_with_context(user)
180
         return uapi.get_user_with_context(user)
181
 
181
 
182
-    @hapic.with_api_doc(tags=[USER_ENDPOINTS_TAG])
182
+    @hapic.with_api_doc(tags=[SWAGGER_TAG__USER_ENDPOINTS])
183
     @require_profile(Group.TIM_ADMIN)
183
     @require_profile(Group.TIM_ADMIN)
184
     @hapic.input_path(UserIdPathSchema())
184
     @hapic.input_path(UserIdPathSchema())
185
     @hapic.output_body(NoContentSchema(), default_http_code=HTTPStatus.NO_CONTENT)  # nopep8
185
     @hapic.output_body(NoContentSchema(), default_http_code=HTTPStatus.NO_CONTENT)  # nopep8
196
         uapi.enable(user=request.candidate_user, do_save=True)
196
         uapi.enable(user=request.candidate_user, do_save=True)
197
         return
197
         return
198
 
198
 
199
-    @hapic.with_api_doc(tags=[USER_ENDPOINTS_TAG])
199
+    @hapic.with_api_doc(tags=[SWAGGER_TAG__USER_ENDPOINTS])
200
     @require_profile(Group.TIM_ADMIN)
200
     @require_profile(Group.TIM_ADMIN)
201
     @hapic.input_path(UserIdPathSchema())
201
     @hapic.input_path(UserIdPathSchema())
202
     @hapic.output_body(NoContentSchema(), default_http_code=HTTPStatus.NO_CONTENT)  # nopep8
202
     @hapic.output_body(NoContentSchema(), default_http_code=HTTPStatus.NO_CONTENT)  # nopep8
213
         uapi.disable(user=request.candidate_user, do_save=True)
213
         uapi.disable(user=request.candidate_user, do_save=True)
214
         return
214
         return
215
 
215
 
216
-    @hapic.with_api_doc(tags=[USER_ENDPOINTS_TAG])
216
+    @hapic.with_api_doc(tags=[SWAGGER_TAG__USER_ENDPOINTS])
217
     @require_profile(Group.TIM_ADMIN)
217
     @require_profile(Group.TIM_ADMIN)
218
     @hapic.input_path(UserIdPathSchema())
218
     @hapic.input_path(UserIdPathSchema())
219
     @hapic.input_body(UserProfileSchema())
219
     @hapic.input_body(UserProfileSchema())
241
         )
241
         )
242
         return
242
         return
243
 
243
 
244
-    @hapic.with_api_doc(tags=[USER_ENDPOINTS_TAG])
244
+    @hapic.with_api_doc(tags=[SWAGGER_TAG__USER_ENDPOINTS])
245
     @require_same_user_or_profile(Group.TIM_ADMIN)
245
     @require_same_user_or_profile(Group.TIM_ADMIN)
246
     @hapic.input_path(UserWorkspaceIdPathSchema())
246
     @hapic.input_path(UserWorkspaceIdPathSchema())
247
     @hapic.input_query(ActiveContentFilterQuerySchema())
247
     @hapic.input_query(ActiveContentFilterQuerySchema())
275
             for content in last_actives
275
             for content in last_actives
276
         ]
276
         ]
277
 
277
 
278
-    @hapic.with_api_doc(tags=[USER_ENDPOINTS_TAG])
278
+    @hapic.with_api_doc(tags=[SWAGGER_TAG__USER_ENDPOINTS])
279
     @require_same_user_or_profile(Group.TIM_ADMIN)
279
     @require_same_user_or_profile(Group.TIM_ADMIN)
280
     @hapic.input_path(UserWorkspaceIdPathSchema())
280
     @hapic.input_path(UserWorkspaceIdPathSchema())
281
     @hapic.input_query(ContentIdsQuerySchema(), as_list=['contents_ids'])
281
     @hapic.input_query(ContentIdsQuerySchema(), as_list=['contents_ids'])
310
             for content in last_actives
310
             for content in last_actives
311
         ]
311
         ]
312
 
312
 
313
-    @hapic.with_api_doc(tags=[USER_ENDPOINTS_TAG])
313
+    @hapic.with_api_doc(tags=[SWAGGER_TAG__USER_ENDPOINTS])
314
     @require_same_user_or_profile(Group.TIM_ADMIN)
314
     @require_same_user_or_profile(Group.TIM_ADMIN)
315
     @hapic.input_path(UserWorkspaceAndContentIdPathSchema())
315
     @hapic.input_path(UserWorkspaceAndContentIdPathSchema())
316
     @hapic.output_body(NoContentSchema(), default_http_code=HTTPStatus.NO_CONTENT)  # nopep8
316
     @hapic.output_body(NoContentSchema(), default_http_code=HTTPStatus.NO_CONTENT)  # nopep8
327
         api.mark_read(request.current_content, do_flush=True)
327
         api.mark_read(request.current_content, do_flush=True)
328
         return
328
         return
329
 
329
 
330
-    @hapic.with_api_doc(tags=[USER_ENDPOINTS_TAG])
330
+    @hapic.with_api_doc(tags=[SWAGGER_TAG__USER_ENDPOINTS])
331
     @require_same_user_or_profile(Group.TIM_ADMIN)
331
     @require_same_user_or_profile(Group.TIM_ADMIN)
332
     @hapic.input_path(UserWorkspaceAndContentIdPathSchema())
332
     @hapic.input_path(UserWorkspaceAndContentIdPathSchema())
333
     @hapic.output_body(NoContentSchema(), default_http_code=HTTPStatus.NO_CONTENT)  # nopep8
333
     @hapic.output_body(NoContentSchema(), default_http_code=HTTPStatus.NO_CONTENT)  # nopep8
344
         api.mark_unread(request.current_content, do_flush=True)
344
         api.mark_unread(request.current_content, do_flush=True)
345
         return
345
         return
346
 
346
 
347
-    @hapic.with_api_doc(tags=[USER_ENDPOINTS_TAG])
347
+    @hapic.with_api_doc(tags=[SWAGGER_TAG__USER_ENDPOINTS])
348
     @require_same_user_or_profile(Group.TIM_ADMIN)
348
     @require_same_user_or_profile(Group.TIM_ADMIN)
349
     @hapic.input_path(UserWorkspaceIdPathSchema())
349
     @hapic.input_path(UserWorkspaceIdPathSchema())
350
     @hapic.output_body(NoContentSchema(), default_http_code=HTTPStatus.NO_CONTENT)  # nopep8
350
     @hapic.output_body(NoContentSchema(), default_http_code=HTTPStatus.NO_CONTENT)  # nopep8

+ 14 - 14
backend/tracim_backend/views/core_api/workspace_controller.py View File

49
 from tracim_backend.models.contents import ContentTypeLegacy as ContentType
49
 from tracim_backend.models.contents import ContentTypeLegacy as ContentType
50
 from tracim_backend.models.revision_protection import new_revision
50
 from tracim_backend.models.revision_protection import new_revision
51
 
51
 
52
-WORKSPACE_ENDPOINTS_TAG = 'Workspaces'
52
+SWAGGER_TAG_WORKSPACE_ENDPOINTS = 'Workspaces'
53
 
53
 
54
 
54
 
55
 class WorkspaceController(Controller):
55
 class WorkspaceController(Controller):
56
 
56
 
57
-    @hapic.with_api_doc(tags=[WORKSPACE_ENDPOINTS_TAG])
57
+    @hapic.with_api_doc(tags=[SWAGGER_TAG_WORKSPACE_ENDPOINTS])
58
     @require_workspace_role(UserRoleInWorkspace.READER)
58
     @require_workspace_role(UserRoleInWorkspace.READER)
59
     @hapic.input_path(WorkspaceIdPathSchema())
59
     @hapic.input_path(WorkspaceIdPathSchema())
60
     @hapic.output_body(WorkspaceSchema())
60
     @hapic.output_body(WorkspaceSchema())
70
         )
70
         )
71
         return wapi.get_workspace_with_context(request.current_workspace)
71
         return wapi.get_workspace_with_context(request.current_workspace)
72
 
72
 
73
-    @hapic.with_api_doc(tags=[WORKSPACE_ENDPOINTS_TAG])
73
+    @hapic.with_api_doc(tags=[SWAGGER_TAG_WORKSPACE_ENDPOINTS])
74
     @hapic.handle_exception(EmptyLabelNotAllowed, HTTPStatus.BAD_REQUEST)
74
     @hapic.handle_exception(EmptyLabelNotAllowed, HTTPStatus.BAD_REQUEST)
75
     @require_workspace_role(UserRoleInWorkspace.WORKSPACE_MANAGER)
75
     @require_workspace_role(UserRoleInWorkspace.WORKSPACE_MANAGER)
76
     @hapic.input_path(WorkspaceIdPathSchema())
76
     @hapic.input_path(WorkspaceIdPathSchema())
94
         )
94
         )
95
         return wapi.get_workspace_with_context(request.current_workspace)
95
         return wapi.get_workspace_with_context(request.current_workspace)
96
 
96
 
97
-    @hapic.with_api_doc(tags=[WORKSPACE_ENDPOINTS_TAG])
97
+    @hapic.with_api_doc(tags=[SWAGGER_TAG_WORKSPACE_ENDPOINTS])
98
     @hapic.handle_exception(EmptyLabelNotAllowed, HTTPStatus.BAD_REQUEST)
98
     @hapic.handle_exception(EmptyLabelNotAllowed, HTTPStatus.BAD_REQUEST)
99
     @require_profile(Group.TIM_MANAGER)
99
     @require_profile(Group.TIM_MANAGER)
100
     @hapic.input_body(WorkspaceCreationSchema())
100
     @hapic.input_body(WorkspaceCreationSchema())
116
         )
116
         )
117
         return wapi.get_workspace_with_context(workspace)
117
         return wapi.get_workspace_with_context(workspace)
118
 
118
 
119
-    @hapic.with_api_doc(tags=[WORKSPACE_ENDPOINTS_TAG])
119
+    @hapic.with_api_doc(tags=[SWAGGER_TAG_WORKSPACE_ENDPOINTS])
120
     @require_workspace_role(UserRoleInWorkspace.READER)
120
     @require_workspace_role(UserRoleInWorkspace.READER)
121
     @hapic.input_path(WorkspaceIdPathSchema())
121
     @hapic.input_path(WorkspaceIdPathSchema())
122
     @hapic.output_body(WorkspaceMemberSchema(many=True))
122
     @hapic.output_body(WorkspaceMemberSchema(many=True))
142
             for user_role in roles
142
             for user_role in roles
143
         ]
143
         ]
144
 
144
 
145
-    @hapic.with_api_doc(tags=[WORKSPACE_ENDPOINTS_TAG])
145
+    @hapic.with_api_doc(tags=[SWAGGER_TAG_WORKSPACE_ENDPOINTS])
146
     @require_workspace_role(UserRoleInWorkspace.WORKSPACE_MANAGER)
146
     @require_workspace_role(UserRoleInWorkspace.WORKSPACE_MANAGER)
147
     @hapic.input_path(WorkspaceAndUserIdPathSchema())
147
     @hapic.input_path(WorkspaceAndUserIdPathSchema())
148
     @hapic.input_body(RoleUpdateSchema())
148
     @hapic.input_body(RoleUpdateSchema())
174
         )
174
         )
175
         return rapi.get_user_role_workspace_with_context(role)
175
         return rapi.get_user_role_workspace_with_context(role)
176
 
176
 
177
-    @hapic.with_api_doc(tags=[WORKSPACE_ENDPOINTS_TAG])
177
+    @hapic.with_api_doc(tags=[SWAGGER_TAG_WORKSPACE_ENDPOINTS])
178
     @hapic.handle_exception(UserCreationFailed, HTTPStatus.BAD_REQUEST)
178
     @hapic.handle_exception(UserCreationFailed, HTTPStatus.BAD_REQUEST)
179
     @require_workspace_role(UserRoleInWorkspace.WORKSPACE_MANAGER)
179
     @require_workspace_role(UserRoleInWorkspace.WORKSPACE_MANAGER)
180
     @hapic.input_path(WorkspaceIdPathSchema())
180
     @hapic.input_path(WorkspaceIdPathSchema())
232
             email_sent=email_sent,
232
             email_sent=email_sent,
233
         )
233
         )
234
 
234
 
235
-    @hapic.with_api_doc(tags=[WORKSPACE_ENDPOINTS_TAG])
235
+    @hapic.with_api_doc(tags=[SWAGGER_TAG_WORKSPACE_ENDPOINTS])
236
     @require_workspace_role(UserRoleInWorkspace.READER)
236
     @require_workspace_role(UserRoleInWorkspace.READER)
237
     @hapic.input_path(WorkspaceIdPathSchema())
237
     @hapic.input_path(WorkspaceIdPathSchema())
238
     @hapic.input_query(FilterContentQuerySchema())
238
     @hapic.input_query(FilterContentQuerySchema())
266
         ]
266
         ]
267
         return contents
267
         return contents
268
 
268
 
269
-    @hapic.with_api_doc(tags=[WORKSPACE_ENDPOINTS_TAG])
269
+    @hapic.with_api_doc(tags=[SWAGGER_TAG_WORKSPACE_ENDPOINTS])
270
     @require_workspace_role(UserRoleInWorkspace.CONTRIBUTOR)
270
     @require_workspace_role(UserRoleInWorkspace.CONTRIBUTOR)
271
     @hapic.handle_exception(EmptyLabelNotAllowed, HTTPStatus.BAD_REQUEST)
271
     @hapic.handle_exception(EmptyLabelNotAllowed, HTTPStatus.BAD_REQUEST)
272
     @hapic.input_path(WorkspaceIdPathSchema())
272
     @hapic.input_path(WorkspaceIdPathSchema())
306
         content = api.get_content_in_context(content)
306
         content = api.get_content_in_context(content)
307
         return content
307
         return content
308
 
308
 
309
-    @hapic.with_api_doc(tags=[WORKSPACE_ENDPOINTS_TAG])
309
+    @hapic.with_api_doc(tags=[SWAGGER_TAG_WORKSPACE_ENDPOINTS])
310
     @hapic.handle_exception(WorkspacesDoNotMatch, HTTPStatus.BAD_REQUEST)
310
     @hapic.handle_exception(WorkspacesDoNotMatch, HTTPStatus.BAD_REQUEST)
311
     @require_workspace_role(UserRoleInWorkspace.CONTENT_MANAGER)
311
     @require_workspace_role(UserRoleInWorkspace.CONTENT_MANAGER)
312
     @require_candidate_workspace_role(UserRoleInWorkspace.CONTENT_MANAGER)
312
     @require_candidate_workspace_role(UserRoleInWorkspace.CONTENT_MANAGER)
358
         )
358
         )
359
         return api.get_content_in_context(updated_content)
359
         return api.get_content_in_context(updated_content)
360
 
360
 
361
-    @hapic.with_api_doc(tags=[WORKSPACE_ENDPOINTS_TAG])
361
+    @hapic.with_api_doc(tags=[SWAGGER_TAG_WORKSPACE_ENDPOINTS])
362
     @require_workspace_role(UserRoleInWorkspace.CONTENT_MANAGER)
362
     @require_workspace_role(UserRoleInWorkspace.CONTENT_MANAGER)
363
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
363
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
364
     @hapic.output_body(NoContentSchema(), default_http_code=HTTPStatus.NO_CONTENT)  # nopep8
364
     @hapic.output_body(NoContentSchema(), default_http_code=HTTPStatus.NO_CONTENT)  # nopep8
390
             api.delete(content)
390
             api.delete(content)
391
         return
391
         return
392
 
392
 
393
-    @hapic.with_api_doc(tags=[WORKSPACE_ENDPOINTS_TAG])
393
+    @hapic.with_api_doc(tags=[SWAGGER_TAG_WORKSPACE_ENDPOINTS])
394
     @require_workspace_role(UserRoleInWorkspace.CONTENT_MANAGER)
394
     @require_workspace_role(UserRoleInWorkspace.CONTENT_MANAGER)
395
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
395
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
396
     @hapic.output_body(NoContentSchema(), default_http_code=HTTPStatus.NO_CONTENT)  # nopep8
396
     @hapic.output_body(NoContentSchema(), default_http_code=HTTPStatus.NO_CONTENT)  # nopep8
423
             api.undelete(content)
423
             api.undelete(content)
424
         return
424
         return
425
 
425
 
426
-    @hapic.with_api_doc(tags=[WORKSPACE_ENDPOINTS_TAG])
426
+    @hapic.with_api_doc(tags=[SWAGGER_TAG_WORKSPACE_ENDPOINTS])
427
     @require_workspace_role(UserRoleInWorkspace.CONTENT_MANAGER)
427
     @require_workspace_role(UserRoleInWorkspace.CONTENT_MANAGER)
428
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
428
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
429
     @hapic.output_body(NoContentSchema(), default_http_code=HTTPStatus.NO_CONTENT)  # nopep8
429
     @hapic.output_body(NoContentSchema(), default_http_code=HTTPStatus.NO_CONTENT)  # nopep8
452
             api.archive(content)
452
             api.archive(content)
453
         return
453
         return
454
 
454
 
455
-    @hapic.with_api_doc(tags=[WORKSPACE_ENDPOINTS_TAG])
455
+    @hapic.with_api_doc(tags=[SWAGGER_TAG_WORKSPACE_ENDPOINTS])
456
     @require_workspace_role(UserRoleInWorkspace.CONTENT_MANAGER)
456
     @require_workspace_role(UserRoleInWorkspace.CONTENT_MANAGER)
457
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
457
     @hapic.input_path(WorkspaceAndContentIdPathSchema())
458
     @hapic.output_body(NoContentSchema(), default_http_code=HTTPStatus.NO_CONTENT)  # nopep8
458
     @hapic.output_body(NoContentSchema(), default_http_code=HTTPStatus.NO_CONTENT)  # nopep8