@@ 292-327 (lines=36) @@ | ||
289 | as_attachment=hapic_data.query.force_download |
|
290 | ) |
|
291 | ||
292 | @hapic.with_api_doc(tags=[SWAGGER_TAG__FILE_ENDPOINTS]) |
|
293 | @require_workspace_role(UserRoleInWorkspace.READER) |
|
294 | @require_content_types([FILE_TYPE]) |
|
295 | @hapic.handle_exception(UnavailablePreview, HTTPStatus.BAD_REQUEST) |
|
296 | @hapic.handle_exception(UnavailablePreviewType, HTTPStatus.BAD_REQUEST) |
|
297 | @hapic.input_path(WorkspaceAndContentRevisionIdPathSchema()) |
|
298 | @hapic.input_query(FileQuerySchema()) |
|
299 | @hapic.output_file([]) |
|
300 | def preview_pdf_full_revision(self, context, request: TracimRequest, hapic_data=None): # nopep8 |
|
301 | """ |
|
302 | Obtain full pdf preview of a specific revision of content. |
|
303 | """ |
|
304 | app_config = request.registry.settings['CFG'] |
|
305 | api = ContentApi( |
|
306 | show_archived=True, |
|
307 | show_deleted=True, |
|
308 | current_user=request.current_user, |
|
309 | session=request.dbsession, |
|
310 | config=app_config, |
|
311 | ) |
|
312 | content = api.get_one( |
|
313 | hapic_data.path.content_id, |
|
314 | content_type=CONTENT_TYPES.Any_SLUG |
|
315 | ) |
|
316 | revision = api.get_one_revision( |
|
317 | revision_id=hapic_data.path.revision_id, |
|
318 | content=content |
|
319 | ) |
|
320 | pdf_preview_path = api.get_full_pdf_preview_path( |
|
321 | revision.revision_id, |
|
322 | ) |
|
323 | filename = "{label}.pdf".format(label=revision.label) |
|
324 | return HapicFile( |
|
325 | file_path=pdf_preview_path, |
|
326 | filename=filename, |
|
327 | as_attachment=hapic_data.query.force_download |
|
328 | ) |
|
329 | ||
330 | @hapic.with_api_doc(tags=[SWAGGER_TAG__FILE_ENDPOINTS]) |
|
@@ 260-289 (lines=30) @@ | ||
257 | as_attachment=hapic_data.query.force_download |
|
258 | ) |
|
259 | ||
260 | @hapic.with_api_doc(tags=[SWAGGER_TAG__FILE_ENDPOINTS]) |
|
261 | @require_workspace_role(UserRoleInWorkspace.READER) |
|
262 | @require_content_types([FILE_TYPE]) |
|
263 | @hapic.handle_exception(UnavailablePreview, HTTPStatus.BAD_REQUEST) |
|
264 | @hapic.handle_exception(UnavailablePreviewType, HTTPStatus.BAD_REQUEST) |
|
265 | @hapic.input_query(FileQuerySchema()) |
|
266 | @hapic.input_path(WorkspaceAndContentIdPathSchema()) |
|
267 | @hapic.output_file([]) |
|
268 | def preview_pdf_full(self, context, request: TracimRequest, hapic_data=None): # nopep8 |
|
269 | """ |
|
270 | Obtain a full pdf preview (all page) of last revision of content. |
|
271 | """ |
|
272 | app_config = request.registry.settings['CFG'] |
|
273 | api = ContentApi( |
|
274 | show_archived=True, |
|
275 | show_deleted=True, |
|
276 | current_user=request.current_user, |
|
277 | session=request.dbsession, |
|
278 | config=app_config, |
|
279 | ) |
|
280 | content = api.get_one( |
|
281 | hapic_data.path.content_id, |
|
282 | content_type=CONTENT_TYPES.Any_SLUG |
|
283 | ) |
|
284 | pdf_preview_path = api.get_full_pdf_preview_path(content.revision_id) |
|
285 | filename = "{label}.pdf".format(label=content.label) |
|
286 | return HapicFile( |
|
287 | file_path=pdf_preview_path, |
|
288 | filename=filename, |
|
289 | as_attachment=hapic_data.query.force_download |
|
290 | ) |
|
291 | ||
292 | @hapic.with_api_doc(tags=[SWAGGER_TAG__FILE_ENDPOINTS]) |