|
@@ -33,7 +33,7 @@ from tracim_backend.models.data import UserRoleInWorkspace
|
33
|
33
|
from tracim_backend.models.context_models import ContentInContext
|
34
|
34
|
from tracim_backend.models.context_models import RevisionInContext
|
35
|
35
|
from tracim_backend.app_models.contents import CONTENT_TYPES
|
36
|
|
-from tracim_backend.app_models.contents import file_type
|
|
36
|
+from tracim_backend.app_models.contents import FILE_TYPE
|
37
|
37
|
from tracim_backend.models.revision_protection import new_revision
|
38
|
38
|
from tracim_backend.exceptions import EmptyLabelNotAllowed
|
39
|
39
|
from tracim_backend.exceptions import PageOfPreviewNotFound
|
|
@@ -50,7 +50,7 @@ class FileController(Controller):
|
50
|
50
|
# File data
|
51
|
51
|
@hapic.with_api_doc(tags=[SWAGGER_TAG__FILE_ENDPOINTS])
|
52
|
52
|
@require_workspace_role(UserRoleInWorkspace.CONTRIBUTOR)
|
53
|
|
- @require_content_types([file_type])
|
|
53
|
+ @require_content_types([FILE_TYPE])
|
54
|
54
|
@hapic.input_path(WorkspaceAndContentIdPathSchema())
|
55
|
55
|
# TODO - G.M - 2018-07-24 - Use hapic for input file
|
56
|
56
|
@hapic.output_body(NoContentSchema(), default_http_code=HTTPStatus.NO_CONTENT) # nopep8
|
|
@@ -88,7 +88,7 @@ class FileController(Controller):
|
88
|
88
|
|
89
|
89
|
@hapic.with_api_doc(tags=[SWAGGER_TAG__FILE_ENDPOINTS])
|
90
|
90
|
@require_workspace_role(UserRoleInWorkspace.READER)
|
91
|
|
- @require_content_types([file_type])
|
|
91
|
+ @require_content_types([FILE_TYPE])
|
92
|
92
|
@hapic.input_path(WorkspaceAndContentIdPathSchema())
|
93
|
93
|
@hapic.output_file([])
|
94
|
94
|
def download_file(self, context, request: TracimRequest, hapic_data=None):
|
|
@@ -115,7 +115,7 @@ class FileController(Controller):
|
115
|
115
|
|
116
|
116
|
@hapic.with_api_doc(tags=[SWAGGER_TAG__FILE_ENDPOINTS])
|
117
|
117
|
@require_workspace_role(UserRoleInWorkspace.READER)
|
118
|
|
- @require_content_types([file_type])
|
|
118
|
+ @require_content_types([FILE_TYPE])
|
119
|
119
|
@hapic.input_path(WorkspaceAndContentRevisionIdPathSchema())
|
120
|
120
|
@hapic.output_file([])
|
121
|
121
|
def download_revisions_file(self, context, request: TracimRequest, hapic_data=None): # nopep8
|
|
@@ -148,7 +148,7 @@ class FileController(Controller):
|
148
|
148
|
# pdf
|
149
|
149
|
@hapic.with_api_doc(tags=[SWAGGER_TAG__FILE_ENDPOINTS])
|
150
|
150
|
@require_workspace_role(UserRoleInWorkspace.READER)
|
151
|
|
- @require_content_types([file_type])
|
|
151
|
+ @require_content_types([FILE_TYPE])
|
152
|
152
|
@hapic.handle_exception(UnavailablePreviewType, HTTPStatus.BAD_REQUEST)
|
153
|
153
|
@hapic.handle_exception(PageOfPreviewNotFound, HTTPStatus.BAD_REQUEST)
|
154
|
154
|
@hapic.input_query(PageQuerySchema())
|
|
@@ -179,7 +179,7 @@ class FileController(Controller):
|
179
|
179
|
|
180
|
180
|
@hapic.with_api_doc(tags=[SWAGGER_TAG__FILE_ENDPOINTS])
|
181
|
181
|
@require_workspace_role(UserRoleInWorkspace.READER)
|
182
|
|
- @require_content_types([file_type])
|
|
182
|
+ @require_content_types([FILE_TYPE])
|
183
|
183
|
@hapic.handle_exception(UnavailablePreviewType, HTTPStatus.BAD_REQUEST)
|
184
|
184
|
@hapic.input_path(WorkspaceAndContentIdPathSchema())
|
185
|
185
|
@hapic.output_file([])
|
|
@@ -204,7 +204,7 @@ class FileController(Controller):
|
204
|
204
|
|
205
|
205
|
@hapic.with_api_doc(tags=[SWAGGER_TAG__FILE_ENDPOINTS])
|
206
|
206
|
@require_workspace_role(UserRoleInWorkspace.READER)
|
207
|
|
- @require_content_types([file_type])
|
|
207
|
+ @require_content_types([FILE_TYPE])
|
208
|
208
|
@hapic.handle_exception(UnavailablePreviewType, HTTPStatus.BAD_REQUEST)
|
209
|
209
|
@hapic.input_path(WorkspaceAndContentRevisionIdPathSchema())
|
210
|
210
|
@hapic.input_query(PageQuerySchema())
|
|
@@ -239,7 +239,7 @@ class FileController(Controller):
|
239
|
239
|
# jpg
|
240
|
240
|
@hapic.with_api_doc(tags=[SWAGGER_TAG__FILE_ENDPOINTS])
|
241
|
241
|
@require_workspace_role(UserRoleInWorkspace.READER)
|
242
|
|
- @require_content_types([file_type])
|
|
242
|
+ @require_content_types([FILE_TYPE])
|
243
|
243
|
@hapic.handle_exception(PageOfPreviewNotFound, HTTPStatus.BAD_REQUEST)
|
244
|
244
|
@hapic.input_path(WorkspaceAndContentIdPathSchema())
|
245
|
245
|
@hapic.input_query(PageQuerySchema())
|
|
@@ -272,7 +272,7 @@ class FileController(Controller):
|
272
|
272
|
|
273
|
273
|
@hapic.with_api_doc(tags=[SWAGGER_TAG__FILE_ENDPOINTS])
|
274
|
274
|
@require_workspace_role(UserRoleInWorkspace.READER)
|
275
|
|
- @require_content_types([file_type])
|
|
275
|
+ @require_content_types([FILE_TYPE])
|
276
|
276
|
@hapic.handle_exception(PageOfPreviewNotFound, HTTPStatus.BAD_REQUEST)
|
277
|
277
|
@hapic.handle_exception(PreviewDimNotAllowed, HTTPStatus.BAD_REQUEST)
|
278
|
278
|
@hapic.input_query(PageQuerySchema())
|
|
@@ -305,7 +305,7 @@ class FileController(Controller):
|
305
|
305
|
|
306
|
306
|
@hapic.with_api_doc(tags=[SWAGGER_TAG__FILE_ENDPOINTS])
|
307
|
307
|
@require_workspace_role(UserRoleInWorkspace.READER)
|
308
|
|
- @require_content_types([file_type])
|
|
308
|
+ @require_content_types([FILE_TYPE])
|
309
|
309
|
@hapic.handle_exception(PageOfPreviewNotFound, HTTPStatus.BAD_REQUEST)
|
310
|
310
|
@hapic.handle_exception(PreviewDimNotAllowed, HTTPStatus.BAD_REQUEST)
|
311
|
311
|
@hapic.input_path(RevisionPreviewSizedPathSchema())
|
|
@@ -342,7 +342,7 @@ class FileController(Controller):
|
342
|
342
|
|
343
|
343
|
@hapic.with_api_doc(tags=[SWAGGER_TAG__FILE_ENDPOINTS])
|
344
|
344
|
@require_workspace_role(UserRoleInWorkspace.READER)
|
345
|
|
- @require_content_types([file_type])
|
|
345
|
+ @require_content_types([FILE_TYPE])
|
346
|
346
|
@hapic.input_path(WorkspaceAndContentIdPathSchema())
|
347
|
347
|
@hapic.output_body(AllowedJpgPreviewDimSchema())
|
348
|
348
|
def allowed_dim_preview_jpg(self, context, request: TracimRequest, hapic_data=None): # nopep8
|
|
@@ -363,7 +363,7 @@ class FileController(Controller):
|
363
|
363
|
# File infos
|
364
|
364
|
@hapic.with_api_doc(tags=[SWAGGER_TAG__FILE_ENDPOINTS])
|
365
|
365
|
@require_workspace_role(UserRoleInWorkspace.READER)
|
366
|
|
- @require_content_types([file_type])
|
|
366
|
+ @require_content_types([FILE_TYPE])
|
367
|
367
|
@hapic.input_path(WorkspaceAndContentIdPathSchema())
|
368
|
368
|
@hapic.output_body(FileContentSchema())
|
369
|
369
|
def get_file_infos(self, context, request: TracimRequest, hapic_data=None) -> ContentInContext: # nopep8
|
|
@@ -387,7 +387,7 @@ class FileController(Controller):
|
387
|
387
|
@hapic.with_api_doc(tags=[SWAGGER_TAG__FILE_ENDPOINTS])
|
388
|
388
|
@hapic.handle_exception(EmptyLabelNotAllowed, HTTPStatus.BAD_REQUEST)
|
389
|
389
|
@require_workspace_role(UserRoleInWorkspace.CONTRIBUTOR)
|
390
|
|
- @require_content_types([file_type])
|
|
390
|
+ @require_content_types([FILE_TYPE])
|
391
|
391
|
@hapic.input_path(WorkspaceAndContentIdPathSchema())
|
392
|
392
|
@hapic.input_body(FileContentModifySchema())
|
393
|
393
|
@hapic.output_body(FileContentSchema())
|
|
@@ -423,7 +423,7 @@ class FileController(Controller):
|
423
|
423
|
|
424
|
424
|
@hapic.with_api_doc(tags=[SWAGGER_TAG__FILE_ENDPOINTS])
|
425
|
425
|
@require_workspace_role(UserRoleInWorkspace.READER)
|
426
|
|
- @require_content_types([file_type])
|
|
426
|
+ @require_content_types([FILE_TYPE])
|
427
|
427
|
@hapic.input_path(WorkspaceAndContentIdPathSchema())
|
428
|
428
|
@hapic.output_body(FileRevisionSchema(many=True))
|
429
|
429
|
def get_file_revisions(
|
|
@@ -456,7 +456,7 @@ class FileController(Controller):
|
456
|
456
|
@hapic.with_api_doc(tags=[SWAGGER_TAG__FILE_ENDPOINTS])
|
457
|
457
|
@hapic.handle_exception(EmptyLabelNotAllowed, HTTPStatus.BAD_REQUEST)
|
458
|
458
|
@require_workspace_role(UserRoleInWorkspace.CONTRIBUTOR)
|
459
|
|
- @require_content_types([file_type])
|
|
459
|
+ @require_content_types([FILE_TYPE])
|
460
|
460
|
@hapic.input_path(WorkspaceAndContentIdPathSchema())
|
461
|
461
|
@hapic.input_body(SetContentStatusSchema())
|
462
|
462
|
@hapic.output_body(NoContentSchema(), default_http_code=HTTPStatus.NO_CONTENT) # nopep8
|