A community-supported supercharged document management system: scan, index and archive all your documents
Python aiangulararchivingdjangodmsdocument-managementdocument-management-systemllmmachine-learningocroptical-character-recognitionpdf
proper filenames for originals and archived documents
Jonas Winkler17a581495ccb
diff --git a/src/documents/models.py b/src/documents/models.pyindex c1ab9a44d..2644657a3 100755--- a/src/documents/models.py+++ b/src/documents/models.py@@ -241,6 +241,10 @@ class Document(models.Model):def file_name(self):return slugify(str(self)) + self.file_type+ @property+ def archive_file_name(self):+ return slugify(str(self)) + ".pdf"+@propertydef file_type(self):return mimetypes.guess_extension(str(self.mime_type))diff --git a/src/documents/views.py b/src/documents/views.pyindex 87d1d31b1..457fa9dc7 100755--- a/src/documents/views.py+++ b/src/documents/views.py@@ -138,8 +138,10 @@ class DocumentViewSet(RetrieveModelMixin,def file_response(self, pk, request, disposition):doc = Document.objects.get(id=pk)mime_type = doc.mime_type+ filename = doc.file_nameif not self.original_requested(request) and os.path.isfile(doc.archive_path): # NOQA: E501file_handle = doc.archive_file+ filename = doc.archive_file_namemime_type = 'application/pdf'elif doc.storage_type == Document.STORAGE_TYPE_UNENCRYPTED:file_handle = doc.source_file@@ -148,7 +150,7 @@ class DocumentViewSet(RetrieveModelMixin,response = HttpResponse(file_handle, content_type=mime_type)response["Content-Disposition"] = '{}; filename="{}"'.format(- disposition, doc.file_name)+ disposition, filename)return response@action(methods=['post'], detail=False)