|
|
@@ -39,7 +39,7 @@ from tracim_backend.exceptions import EmptyLabelNotAllowed
|
|
39
|
39
|
from tracim_backend.exceptions import PageOfPreviewNotFound
|
|
40
|
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
|
45
|
class FileController(Controller):
|
|
|
@@ -48,7 +48,7 @@ class FileController(Controller):
|
|
48
|
48
|
"""
|
|
49
|
49
|
|
|
50
|
50
|
# File data
|
|
51
|
|
- @hapic.with_api_doc(tags=[FILE_ENDPOINTS_TAG])
|
|
|
51
|
+ @hapic.with_api_doc(tags=[SWAGGER_TAG__FILE_ENDPOINTS])
|
|
52
|
52
|
@require_workspace_role(UserRoleInWorkspace.CONTRIBUTOR)
|
|
53
|
53
|
@require_content_types([file_type])
|
|
54
|
54
|
@hapic.input_path(WorkspaceAndContentIdPathSchema())
|
|
|
@@ -84,7 +84,7 @@ class FileController(Controller):
|
|
84
|
84
|
|
|
85
|
85
|
return
|
|
86
|
86
|
|
|
87
|
|
- @hapic.with_api_doc(tags=[FILE_ENDPOINTS_TAG])
|
|
|
87
|
+ @hapic.with_api_doc(tags=[SWAGGER_TAG__FILE_ENDPOINTS])
|
|
88
|
88
|
@require_workspace_role(UserRoleInWorkspace.READER)
|
|
89
|
89
|
@require_content_types([file_type])
|
|
90
|
90
|
@hapic.input_path(WorkspaceAndContentIdPathSchema())
|
|
|
@@ -109,7 +109,7 @@ class FileController(Controller):
|
|
109
|
109
|
response.app_iter = FileIter(file)
|
|
110
|
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
|
113
|
@require_workspace_role(UserRoleInWorkspace.READER)
|
|
114
|
114
|
@require_content_types([file_type])
|
|
115
|
115
|
@hapic.input_path(WorkspaceAndContentRevisionIdPathSchema())
|
|
|
@@ -140,7 +140,7 @@ class FileController(Controller):
|
|
140
|
140
|
|
|
141
|
141
|
# preview
|
|
142
|
142
|
# pdf
|
|
143
|
|
- @hapic.with_api_doc(tags=[FILE_ENDPOINTS_TAG])
|
|
|
143
|
+ @hapic.with_api_doc(tags=[SWAGGER_TAG__FILE_ENDPOINTS])
|
|
144
|
144
|
@require_workspace_role(UserRoleInWorkspace.READER)
|
|
145
|
145
|
@require_content_types([file_type])
|
|
146
|
146
|
@hapic.handle_exception(UnavailablePreviewType, HTTPStatus.BAD_REQUEST)
|
|
|
@@ -169,7 +169,7 @@ class FileController(Controller):
|
|
169
|
169
|
)
|
|
170
|
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
|
173
|
@require_workspace_role(UserRoleInWorkspace.READER)
|
|
174
|
174
|
@require_content_types([file_type])
|
|
175
|
175
|
@hapic.handle_exception(UnavailablePreviewType, HTTPStatus.BAD_REQUEST)
|
|
|
@@ -192,7 +192,7 @@ class FileController(Controller):
|
|
192
|
192
|
pdf_preview_path = api.get_full_pdf_preview_path(content.revision_id)
|
|
193
|
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
|
196
|
@require_workspace_role(UserRoleInWorkspace.READER)
|
|
197
|
197
|
@require_content_types([file_type])
|
|
198
|
198
|
@hapic.handle_exception(UnavailablePreviewType, HTTPStatus.BAD_REQUEST)
|
|
|
@@ -225,7 +225,7 @@ class FileController(Controller):
|
|
225
|
225
|
return FileResponse(pdf_preview_path)
|
|
226
|
226
|
|
|
227
|
227
|
# jpg
|
|
228
|
|
- @hapic.with_api_doc(tags=[FILE_ENDPOINTS_TAG])
|
|
|
228
|
+ @hapic.with_api_doc(tags=[SWAGGER_TAG__FILE_ENDPOINTS])
|
|
229
|
229
|
@require_workspace_role(UserRoleInWorkspace.READER)
|
|
230
|
230
|
@require_content_types([file_type])
|
|
231
|
231
|
@hapic.handle_exception(PageOfPreviewNotFound, HTTPStatus.BAD_REQUEST)
|
|
|
@@ -256,7 +256,7 @@ class FileController(Controller):
|
|
256
|
256
|
)
|
|
257
|
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
|
260
|
@require_workspace_role(UserRoleInWorkspace.READER)
|
|
261
|
261
|
@require_content_types([file_type])
|
|
262
|
262
|
@hapic.handle_exception(PageOfPreviewNotFound, HTTPStatus.BAD_REQUEST)
|
|
|
@@ -287,7 +287,7 @@ class FileController(Controller):
|
|
287
|
287
|
)
|
|
288
|
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
|
291
|
@require_workspace_role(UserRoleInWorkspace.READER)
|
|
292
|
292
|
@require_content_types([file_type])
|
|
293
|
293
|
@hapic.handle_exception(PageOfPreviewNotFound, HTTPStatus.BAD_REQUEST)
|
|
|
@@ -322,7 +322,7 @@ class FileController(Controller):
|
|
322
|
322
|
)
|
|
323
|
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
|
326
|
@require_workspace_role(UserRoleInWorkspace.READER)
|
|
327
|
327
|
@require_content_types([file_type])
|
|
328
|
328
|
@hapic.input_path(WorkspaceAndContentIdPathSchema())
|
|
|
@@ -341,7 +341,7 @@ class FileController(Controller):
|
|
341
|
341
|
return api.get_jpg_preview_allowed_dim()
|
|
342
|
342
|
|
|
343
|
343
|
# File infos
|
|
344
|
|
- @hapic.with_api_doc(tags=[FILE_ENDPOINTS_TAG])
|
|
|
344
|
+ @hapic.with_api_doc(tags=[SWAGGER_TAG__FILE_ENDPOINTS])
|
|
345
|
345
|
@require_workspace_role(UserRoleInWorkspace.READER)
|
|
346
|
346
|
@require_content_types([file_type])
|
|
347
|
347
|
@hapic.input_path(WorkspaceAndContentIdPathSchema())
|
|
|
@@ -362,7 +362,7 @@ class FileController(Controller):
|
|
362
|
362
|
)
|
|
363
|
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
|
366
|
@hapic.handle_exception(EmptyLabelNotAllowed, HTTPStatus.BAD_REQUEST)
|
|
367
|
367
|
@require_workspace_role(UserRoleInWorkspace.CONTRIBUTOR)
|
|
368
|
368
|
@require_content_types([file_type])
|
|
|
@@ -397,7 +397,7 @@ class FileController(Controller):
|
|
397
|
397
|
api.save(content)
|
|
398
|
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
|
401
|
@require_workspace_role(UserRoleInWorkspace.READER)
|
|
402
|
402
|
@require_content_types([file_type])
|
|
403
|
403
|
@hapic.input_path(WorkspaceAndContentIdPathSchema())
|
|
|
@@ -427,7 +427,7 @@ class FileController(Controller):
|
|
427
|
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
|
431
|
@hapic.handle_exception(EmptyLabelNotAllowed, HTTPStatus.BAD_REQUEST)
|
|
432
|
432
|
@require_workspace_role(UserRoleInWorkspace.CONTRIBUTOR)
|
|
433
|
433
|
@require_content_types([file_type])
|