|
@@ -34,6 +34,7 @@ from tracim_backend.exceptions import WorkspacesDoNotMatch
|
34
|
34
|
from tracim_backend.exceptions import ParentNotFound
|
35
|
35
|
from tracim_backend.views.controllers import Controller
|
36
|
36
|
from tracim_backend.views.core_api.schemas import FilterContentQuerySchema
|
|
37
|
+from tracim_backend.views.core_api.schemas import ContentIdPathSchema
|
37
|
38
|
from tracim_backend.views.core_api.schemas import WorkspaceMemberCreationSchema
|
38
|
39
|
from tracim_backend.views.core_api.schemas import WorkspaceMemberInviteSchema
|
39
|
40
|
from tracim_backend.views.core_api.schemas import RoleUpdateSchema
|
|
@@ -312,7 +313,7 @@ class WorkspaceController(Controller):
|
312
|
313
|
@require_workspace_role(UserRoleInWorkspace.READER)
|
313
|
314
|
@hapic.input_path(WorkspaceAndContentIdPathSchema())
|
314
|
315
|
@hapic.output_body(NoContentSchema(), default_http_code=HTTPStatus.FOUND) # nopep8
|
315
|
|
- def get_content(
|
|
316
|
+ def get_content_from_workspace(
|
316
|
317
|
self,
|
317
|
318
|
context,
|
318
|
319
|
request: TracimRequest,
|
|
@@ -335,6 +336,39 @@ class WorkspaceController(Controller):
|
335
|
336
|
)
|
336
|
337
|
|
337
|
338
|
@hapic.with_api_doc(tags=[SWAGGER_TAG_WORKSPACE_ENDPOINTS])
|
|
339
|
+ @hapic.input_path(ContentIdPathSchema())
|
|
340
|
+ @hapic.output_body(NoContentSchema(), default_http_code=HTTPStatus.FOUND) # nopep8
|
|
341
|
+ def get_content(
|
|
342
|
+ self,
|
|
343
|
+ context,
|
|
344
|
+ request: TracimRequest,
|
|
345
|
+ hapic_data=None,
|
|
346
|
+ ) -> None:
|
|
347
|
+ """
|
|
348
|
+ redirect to correct content file endpoint
|
|
349
|
+ """
|
|
350
|
+ app_config = request.registry.settings['CFG']
|
|
351
|
+ api = ContentApi(
|
|
352
|
+ current_user=request.current_user,
|
|
353
|
+ session=request.dbsession,
|
|
354
|
+ config=app_config,
|
|
355
|
+ )
|
|
356
|
+ content = api.get_one(
|
|
357
|
+ content_id=hapic_data.path['content_id'],
|
|
358
|
+ content_type=CONTENT_TYPES.Any_SLUG
|
|
359
|
+ )
|
|
360
|
+ content_type = CONTENT_TYPES.get_one_by_slug(content.type).slug
|
|
361
|
+ # TODO - G.M - 2018-08-03 - Jsonify redirect response ?
|
|
362
|
+ raise HTTPFound(
|
|
363
|
+ "{base_url}workspaces/{workspace_id}/{content_type}s/{content_id}".format(
|
|
364
|
+ base_url=BASE_API_V2,
|
|
365
|
+ workspace_id=content.workspace_id,
|
|
366
|
+ content_type=content_type,
|
|
367
|
+ content_id=content.content_id,
|
|
368
|
+ )
|
|
369
|
+ )
|
|
370
|
+
|
|
371
|
+ @hapic.with_api_doc(tags=[SWAGGER_TAG_WORKSPACE_ENDPOINTS])
|
338
|
372
|
@hapic.handle_exception(WorkspacesDoNotMatch, HTTPStatus.BAD_REQUEST)
|
339
|
373
|
@require_workspace_role(UserRoleInWorkspace.CONTENT_MANAGER)
|
340
|
374
|
@require_candidate_workspace_role(UserRoleInWorkspace.CONTENT_MANAGER)
|
|
@@ -544,8 +578,11 @@ class WorkspaceController(Controller):
|
544
|
578
|
configurator.add_route('create_generic_content', '/workspaces/{workspace_id}/contents', request_method='POST') # nopep8
|
545
|
579
|
configurator.add_view(self.create_generic_empty_content, route_name='create_generic_content') # nopep8
|
546
|
580
|
# Get Content
|
547
|
|
- configurator.add_route('get_content', '/workspaces/{workspace_id}/contents/{content_id}', request_method='GET') # nopep8
|
|
581
|
+ configurator.add_route('get_content', '/contents/{content_id}', request_method='GET') # nopep8
|
548
|
582
|
configurator.add_view(self.get_content, route_name='get_content')
|
|
583
|
+ # Get Content From workspace
|
|
584
|
+ configurator.add_route('get_content_from_workspace', '/workspaces/{workspace_id}/contents/{content_id}', request_method='GET') # nopep8
|
|
585
|
+ configurator.add_view(self.get_content_from_workspace, route_name='get_content_from_workspace') # nopep8
|
549
|
586
|
# Move Content
|
550
|
587
|
configurator.add_route('move_content', '/workspaces/{workspace_id}/contents/{content_id}/move', request_method='PUT') # nopep8
|
551
|
588
|
configurator.add_view(self.move_content, route_name='move_content') # nopep8
|