|
|
|
|
43
|
|
43
|
|
44
|
|
44
|
|
45
|
class FileController(Controller):
|
45
|
class FileController(Controller):
|
|
|
46
|
+ """
|
|
|
47
|
+ Endpoints for File Content
|
|
|
48
|
+ """
|
46
|
|
49
|
|
47
|
# File data
|
50
|
# File data
|
48
|
@hapic.with_api_doc(tags=[FILE_ENDPOINTS_TAG])
|
51
|
@hapic.with_api_doc(tags=[FILE_ENDPOINTS_TAG])
|
49
|
@require_workspace_role(UserRoleInWorkspace.CONTRIBUTOR)
|
52
|
@require_workspace_role(UserRoleInWorkspace.CONTRIBUTOR)
|
50
|
@require_content_types([file_type])
|
53
|
@require_content_types([file_type])
|
51
|
@hapic.input_path(WorkspaceAndContentIdPathSchema())
|
54
|
@hapic.input_path(WorkspaceAndContentIdPathSchema())
|
52
|
- #@hapic.input_files()
|
|
|
|
|
55
|
+ # TODO - G.M - 2018-07-24 - Use hapic for input file
|
53
|
@hapic.output_body(NoContentSchema(), default_http_code=HTTPStatus.NO_CONTENT) # nopep8
|
56
|
@hapic.output_body(NoContentSchema(), default_http_code=HTTPStatus.NO_CONTENT) # nopep8
|
54
|
def upload_file(self, context, request: TracimRequest, hapic_data=None):
|
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
|
app_config = request.registry.settings['CFG']
|
62
|
app_config = request.registry.settings['CFG']
|
56
|
api = ContentApi(
|
63
|
api = ContentApi(
|
57
|
current_user=request.current_user,
|
64
|
current_user=request.current_user,
|
|
|
|
|
83
|
@hapic.input_path(WorkspaceAndContentIdPathSchema())
|
90
|
@hapic.input_path(WorkspaceAndContentIdPathSchema())
|
84
|
@hapic.output_file([])
|
91
|
@hapic.output_file([])
|
85
|
def download_file(self, context, request: TracimRequest, hapic_data=None):
|
92
|
def download_file(self, context, request: TracimRequest, hapic_data=None):
|
|
|
93
|
+ """
|
|
|
94
|
+ Download raw file of last revision of content.
|
|
|
95
|
+ """
|
86
|
app_config = request.registry.settings['CFG']
|
96
|
app_config = request.registry.settings['CFG']
|
87
|
api = ContentApi(
|
97
|
api = ContentApi(
|
88
|
current_user=request.current_user,
|
98
|
current_user=request.current_user,
|
|
|
|
|
105
|
@hapic.input_path(WorkspaceAndContentRevisionIdPathSchema())
|
115
|
@hapic.input_path(WorkspaceAndContentRevisionIdPathSchema())
|
106
|
@hapic.output_file([])
|
116
|
@hapic.output_file([])
|
107
|
def download_revisions_file(self, context, request: TracimRequest, hapic_data=None): # nopep8
|
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
|
app_config = request.registry.settings['CFG']
|
121
|
app_config = request.registry.settings['CFG']
|
109
|
api = ContentApi(
|
122
|
api = ContentApi(
|
110
|
current_user=request.current_user,
|
123
|
current_user=request.current_user,
|
|
|
|
|
136
|
@hapic.input_path(WorkspaceAndContentIdPathSchema())
|
149
|
@hapic.input_path(WorkspaceAndContentIdPathSchema())
|
137
|
@hapic.output_file([])
|
150
|
@hapic.output_file([])
|
138
|
def preview_pdf(self, context, request: TracimRequest, hapic_data=None):
|
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
|
app_config = request.registry.settings['CFG']
|
155
|
app_config = request.registry.settings['CFG']
|
140
|
api = ContentApi(
|
156
|
api = ContentApi(
|
141
|
current_user=request.current_user,
|
157
|
current_user=request.current_user,
|
|
|
|
|
159
|
@hapic.handle_exception(UnavailablePreviewType, HTTPStatus.BAD_REQUEST)
|
175
|
@hapic.handle_exception(UnavailablePreviewType, HTTPStatus.BAD_REQUEST)
|
160
|
@hapic.input_path(WorkspaceAndContentIdPathSchema())
|
176
|
@hapic.input_path(WorkspaceAndContentIdPathSchema())
|
161
|
@hapic.output_file([])
|
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
|
app_config = request.registry.settings['CFG']
|
182
|
app_config = request.registry.settings['CFG']
|
164
|
api = ContentApi(
|
183
|
api = ContentApi(
|
165
|
current_user=request.current_user,
|
184
|
current_user=request.current_user,
|
|
|
|
|
180
|
@hapic.input_path(WorkspaceAndContentRevisionIdPathSchema())
|
199
|
@hapic.input_path(WorkspaceAndContentRevisionIdPathSchema())
|
181
|
@hapic.input_query(PageQuerySchema())
|
200
|
@hapic.input_query(PageQuerySchema())
|
182
|
@hapic.output_file([])
|
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
|
app_config = request.registry.settings['CFG']
|
206
|
app_config = request.registry.settings['CFG']
|
185
|
api = ContentApi(
|
207
|
api = ContentApi(
|
186
|
current_user=request.current_user,
|
208
|
current_user=request.current_user,
|
|
|
|
|
211
|
@hapic.input_query(PageQuerySchema())
|
233
|
@hapic.input_query(PageQuerySchema())
|
212
|
@hapic.output_file([])
|
234
|
@hapic.output_file([])
|
213
|
def preview_jpg(self, context, request: TracimRequest, hapic_data=None):
|
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
|
app_config = request.registry.settings['CFG']
|
239
|
app_config = request.registry.settings['CFG']
|
215
|
api = ContentApi(
|
240
|
api = ContentApi(
|
216
|
current_user=request.current_user,
|
241
|
current_user=request.current_user,
|
|
|
|
|
239
|
@hapic.input_query(PageQuerySchema())
|
264
|
@hapic.input_query(PageQuerySchema())
|
240
|
@hapic.input_path(ContentPreviewSizedPathSchema())
|
265
|
@hapic.input_path(ContentPreviewSizedPathSchema())
|
241
|
@hapic.output_file([])
|
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
|
app_config = request.registry.settings['CFG']
|
271
|
app_config = request.registry.settings['CFG']
|
244
|
api = ContentApi(
|
272
|
api = ContentApi(
|
245
|
current_user=request.current_user,
|
273
|
current_user=request.current_user,
|
|
|
|
|
267
|
@hapic.input_path(RevisionPreviewSizedPathSchema())
|
295
|
@hapic.input_path(RevisionPreviewSizedPathSchema())
|
268
|
@hapic.input_query(PageQuerySchema())
|
296
|
@hapic.input_query(PageQuerySchema())
|
269
|
@hapic.output_file([])
|
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
|
app_config = request.registry.settings['CFG']
|
302
|
app_config = request.registry.settings['CFG']
|
272
|
api = ContentApi(
|
303
|
api = ContentApi(
|
273
|
current_user=request.current_user,
|
304
|
current_user=request.current_user,
|
|
|
|
|
296
|
@require_content_types([file_type])
|
327
|
@require_content_types([file_type])
|
297
|
@hapic.input_path(WorkspaceAndContentIdPathSchema())
|
328
|
@hapic.input_path(WorkspaceAndContentIdPathSchema())
|
298
|
@hapic.output_body(AllowedJpgPreviewDimSchema())
|
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
|
app_config = request.registry.settings['CFG']
|
335
|
app_config = request.registry.settings['CFG']
|
301
|
api = ContentApi(
|
336
|
api = ContentApi(
|
302
|
current_user=request.current_user,
|
337
|
current_user=request.current_user,
|
|
|
|
|
426
|
return
|
461
|
return
|
427
|
|
462
|
|
428
|
def bind(self, configurator: Configurator) -> None:
|
463
|
def bind(self, configurator: Configurator) -> None:
|
|
|
464
|
+ """
|
|
|
465
|
+ Add route to configurator.
|
|
|
466
|
+ """
|
429
|
|
467
|
|
430
|
# file info #
|
468
|
# file info #
|
431
|
# Get file info
|
469
|
# Get file info
|