|
@@ -43,15 +43,22 @@ FILE_ENDPOINTS_TAG = 'Files'
|
43
|
43
|
|
44
|
44
|
|
45
|
45
|
class FileController(Controller):
|
|
46
|
+ """
|
|
47
|
+ Endpoints for File Content
|
|
48
|
+ """
|
46
|
49
|
|
47
|
50
|
# File data
|
48
|
51
|
@hapic.with_api_doc(tags=[FILE_ENDPOINTS_TAG])
|
49
|
52
|
@require_workspace_role(UserRoleInWorkspace.CONTRIBUTOR)
|
50
|
53
|
@require_content_types([file_type])
|
51
|
54
|
@hapic.input_path(WorkspaceAndContentIdPathSchema())
|
52
|
|
- #@hapic.input_files()
|
|
55
|
+ # TODO - G.M - 2018-07-24 - Use hapic for input file
|
53
|
56
|
@hapic.output_body(NoContentSchema(), default_http_code=HTTPStatus.NO_CONTENT) # nopep8
|
54
|
57
|
def upload_file(self, context, request: TracimRequest, hapic_data=None):
|
|
58
|
+ """
|
|
59
|
+ Upload a new version of raw file of content. This will create a new
|
|
60
|
+ revision.
|
|
61
|
+ """
|
55
|
62
|
app_config = request.registry.settings['CFG']
|
56
|
63
|
api = ContentApi(
|
57
|
64
|
current_user=request.current_user,
|
|
@@ -83,6 +90,9 @@ class FileController(Controller):
|
83
|
90
|
@hapic.input_path(WorkspaceAndContentIdPathSchema())
|
84
|
91
|
@hapic.output_file([])
|
85
|
92
|
def download_file(self, context, request: TracimRequest, hapic_data=None):
|
|
93
|
+ """
|
|
94
|
+ Download raw file of last revision of content.
|
|
95
|
+ """
|
86
|
96
|
app_config = request.registry.settings['CFG']
|
87
|
97
|
api = ContentApi(
|
88
|
98
|
current_user=request.current_user,
|
|
@@ -105,6 +115,9 @@ class FileController(Controller):
|
105
|
115
|
@hapic.input_path(WorkspaceAndContentRevisionIdPathSchema())
|
106
|
116
|
@hapic.output_file([])
|
107
|
117
|
def download_revisions_file(self, context, request: TracimRequest, hapic_data=None): # nopep8
|
|
118
|
+ """
|
|
119
|
+ Download raw file for specific revision of content.
|
|
120
|
+ """
|
108
|
121
|
app_config = request.registry.settings['CFG']
|
109
|
122
|
api = ContentApi(
|
110
|
123
|
current_user=request.current_user,
|
|
@@ -136,6 +149,9 @@ class FileController(Controller):
|
136
|
149
|
@hapic.input_path(WorkspaceAndContentIdPathSchema())
|
137
|
150
|
@hapic.output_file([])
|
138
|
151
|
def preview_pdf(self, context, request: TracimRequest, hapic_data=None):
|
|
152
|
+ """
|
|
153
|
+ Obtain a specific page pdf preview of last revision of content.
|
|
154
|
+ """
|
139
|
155
|
app_config = request.registry.settings['CFG']
|
140
|
156
|
api = ContentApi(
|
141
|
157
|
current_user=request.current_user,
|
|
@@ -159,7 +175,10 @@ class FileController(Controller):
|
159
|
175
|
@hapic.handle_exception(UnavailablePreviewType, HTTPStatus.BAD_REQUEST)
|
160
|
176
|
@hapic.input_path(WorkspaceAndContentIdPathSchema())
|
161
|
177
|
@hapic.output_file([])
|
162
|
|
- def preview_pdf_full(self, context, request: TracimRequest, hapic_data=None):
|
|
178
|
+ def preview_pdf_full(self, context, request: TracimRequest, hapic_data=None): # nopep8
|
|
179
|
+ """
|
|
180
|
+ Obtain a full pdf preview (all page) of last revision of content.
|
|
181
|
+ """
|
163
|
182
|
app_config = request.registry.settings['CFG']
|
164
|
183
|
api = ContentApi(
|
165
|
184
|
current_user=request.current_user,
|
|
@@ -180,7 +199,10 @@ class FileController(Controller):
|
180
|
199
|
@hapic.input_path(WorkspaceAndContentRevisionIdPathSchema())
|
181
|
200
|
@hapic.input_query(PageQuerySchema())
|
182
|
201
|
@hapic.output_file([])
|
183
|
|
- def preview_pdf_revision(self, context, request: TracimRequest, hapic_data=None):
|
|
202
|
+ def preview_pdf_revision(self, context, request: TracimRequest, hapic_data=None): # nopep8
|
|
203
|
+ """
|
|
204
|
+ Obtain a specific page pdf preview of a specific revision of content.
|
|
205
|
+ """
|
184
|
206
|
app_config = request.registry.settings['CFG']
|
185
|
207
|
api = ContentApi(
|
186
|
208
|
current_user=request.current_user,
|
|
@@ -211,6 +233,9 @@ class FileController(Controller):
|
211
|
233
|
@hapic.input_query(PageQuerySchema())
|
212
|
234
|
@hapic.output_file([])
|
213
|
235
|
def preview_jpg(self, context, request: TracimRequest, hapic_data=None):
|
|
236
|
+ """
|
|
237
|
+ Obtain normally sied jpg preview of last revision of content.
|
|
238
|
+ """
|
214
|
239
|
app_config = request.registry.settings['CFG']
|
215
|
240
|
api = ContentApi(
|
216
|
241
|
current_user=request.current_user,
|
|
@@ -239,7 +264,10 @@ class FileController(Controller):
|
239
|
264
|
@hapic.input_query(PageQuerySchema())
|
240
|
265
|
@hapic.input_path(ContentPreviewSizedPathSchema())
|
241
|
266
|
@hapic.output_file([])
|
242
|
|
- def sized_preview_jpg(self, context, request: TracimRequest, hapic_data=None):
|
|
267
|
+ def sized_preview_jpg(self, context, request: TracimRequest, hapic_data=None): # nopep8
|
|
268
|
+ """
|
|
269
|
+ Obtain resized jpg preview of last revision of content.
|
|
270
|
+ """
|
243
|
271
|
app_config = request.registry.settings['CFG']
|
244
|
272
|
api = ContentApi(
|
245
|
273
|
current_user=request.current_user,
|
|
@@ -267,7 +295,10 @@ class FileController(Controller):
|
267
|
295
|
@hapic.input_path(RevisionPreviewSizedPathSchema())
|
268
|
296
|
@hapic.input_query(PageQuerySchema())
|
269
|
297
|
@hapic.output_file([])
|
270
|
|
- def sized_preview_jpg_revision(self, context, request: TracimRequest, hapic_data=None):
|
|
298
|
+ def sized_preview_jpg_revision(self, context, request: TracimRequest, hapic_data=None): # nopep8
|
|
299
|
+ """
|
|
300
|
+ Obtain resized jpg preview of a specific revision of content.
|
|
301
|
+ """
|
271
|
302
|
app_config = request.registry.settings['CFG']
|
272
|
303
|
api = ContentApi(
|
273
|
304
|
current_user=request.current_user,
|
|
@@ -296,7 +327,11 @@ class FileController(Controller):
|
296
|
327
|
@require_content_types([file_type])
|
297
|
328
|
@hapic.input_path(WorkspaceAndContentIdPathSchema())
|
298
|
329
|
@hapic.output_body(AllowedJpgPreviewDimSchema())
|
299
|
|
- def allowed_dim_preview_jpg(self, context, request: TracimRequest, hapic_data=None):
|
|
330
|
+ def allowed_dim_preview_jpg(self, context, request: TracimRequest, hapic_data=None): # nopep8
|
|
331
|
+ """
|
|
332
|
+ Get allowed dimensions of jpg preview. If restricted is true,
|
|
333
|
+ only those dimensions are strictly accepted.
|
|
334
|
+ """
|
300
|
335
|
app_config = request.registry.settings['CFG']
|
301
|
336
|
api = ContentApi(
|
302
|
337
|
current_user=request.current_user,
|
|
@@ -426,6 +461,9 @@ class FileController(Controller):
|
426
|
461
|
return
|
427
|
462
|
|
428
|
463
|
def bind(self, configurator: Configurator) -> None:
|
|
464
|
+ """
|
|
465
|
+ Add route to configurator.
|
|
466
|
+ """
|
429
|
467
|
|
430
|
468
|
# file info #
|
431
|
469
|
# Get file info
|