|
@@ -20,6 +20,7 @@ from tracim.extensions import hapic
|
20
|
20
|
from tracim.lib.core.content import ContentApi
|
21
|
21
|
from tracim.views.controllers import Controller
|
22
|
22
|
from tracim.views.core_api.schemas import FileContentSchema
|
|
23
|
+from tracim.views.core_api.schemas import WorkspaceAndContentRevisionIdPathSchema # nopep8
|
23
|
24
|
from tracim.views.core_api.schemas import FileRevisionSchema
|
24
|
25
|
from tracim.views.core_api.schemas import SetContentStatusSchema
|
25
|
26
|
from tracim.views.core_api.schemas import FileContentModifySchema
|
|
@@ -97,10 +98,28 @@ class FileController(Controller):
|
97
|
98
|
@hapic.with_api_doc(tags=[FILE_ENDPOINTS_TAG])
|
98
|
99
|
@require_workspace_role(UserRoleInWorkspace.READER)
|
99
|
100
|
@require_content_types([file_type])
|
100
|
|
- @hapic.input_path(WorkspaceAndContentIdPathSchema())
|
|
101
|
+ @hapic.input_path(WorkspaceAndContentRevisionIdPathSchema())
|
101
|
102
|
@hapic.output_file([])
|
102
|
|
- def download_revisions_file(self, context, request: TracimRequest, hapic_data=None):
|
103
|
|
- raise NotImplemented()
|
|
103
|
+ def download_revisions_file(self, context, request: TracimRequest, hapic_data=None): # nopep8
|
|
104
|
+ app_config = request.registry.settings['CFG']
|
|
105
|
+ api = ContentApi(
|
|
106
|
+ current_user=request.current_user,
|
|
107
|
+ session=request.dbsession,
|
|
108
|
+ config=app_config,
|
|
109
|
+ )
|
|
110
|
+ content = api.get_one(
|
|
111
|
+ hapic_data.path.content_id,
|
|
112
|
+ content_type=ContentType.Any
|
|
113
|
+ )
|
|
114
|
+ revision = api.get_one_revision(
|
|
115
|
+ revision_id=hapic_data.path.revision_id,
|
|
116
|
+ content=content
|
|
117
|
+ )
|
|
118
|
+ file = DepotManager.get().get(revision.depot_file)
|
|
119
|
+ response = request.response
|
|
120
|
+ response.content_type = file.content_type
|
|
121
|
+ response.app_iter = FileIter(file)
|
|
122
|
+ return response
|
104
|
123
|
|
105
|
124
|
# preview
|
106
|
125
|
# pdf
|
|
@@ -335,7 +354,7 @@ class FileController(Controller):
|
335
|
354
|
# download raw file of revision
|
336
|
355
|
configurator.add_route(
|
337
|
356
|
'download_revision',
|
338
|
|
- '/workspaces/{workspace_id}/files/{content_id}/revisions/{content_revision}/raw', # nopep8
|
|
357
|
+ '/workspaces/{workspace_id}/files/{content_id}/revisions/{revision_id}/raw', # nopep8
|
339
|
358
|
request_method='GET'
|
340
|
359
|
)
|
341
|
360
|
configurator.add_view(self.download_revisions_file, route_name='download_revision') # nopep8
|