Refactor and implement download code natively
- Use modified port of Django 2.2 FileResponse. - Remove Django DownloadView library. Signed-off-by: Roberto Rosario <roberto.rosario@mayan-edms.com>
This commit is contained in:
@@ -114,12 +114,10 @@ class DocumentContentViewsTestCase(
|
||||
|
||||
def test_document_parsing_download_view_no_permission(self):
|
||||
response = self._request_test_document_content_download_view()
|
||||
self.assertEqual(response.status_code, 403)
|
||||
self.assertEqual(response.status_code, 404)
|
||||
|
||||
def test_document_parsing_download_view_with_access(self):
|
||||
self.expected_content_types = (
|
||||
'application/octet-stream; charset=utf-8',
|
||||
)
|
||||
self.expected_content_types = ('text/html; charset=utf-8',)
|
||||
self.grant_access(
|
||||
obj=self.test_document, permission=permission_content_view
|
||||
)
|
||||
|
||||
@@ -75,13 +75,11 @@ class DocumentContentDownloadView(SingleObjectDownloadView):
|
||||
model = Document
|
||||
object_permission = permission_content_view
|
||||
|
||||
def get_file(self):
|
||||
file_object = DocumentContentDownloadView.TextIteratorIO(
|
||||
iterator=get_document_content(document=self.get_object())
|
||||
)
|
||||
return DocumentContentDownloadView.VirtualFile(
|
||||
file=file_object, name='{}-content'.format(self.get_object())
|
||||
)
|
||||
def get_download_file_object(self):
|
||||
return get_document_content(document=self.object)
|
||||
|
||||
def get_download_filename(self):
|
||||
return '{}-content'.format(self.object)
|
||||
|
||||
|
||||
class DocumentPageContentView(SingleObjectDetailView):
|
||||
|
||||
Reference in New Issue
Block a user