A community-supported supercharged document management system: scan, index and archive all your documents
Python aiangulararchivingdjangodmsdocument-managementdocument-management-systemllmmachine-learningocroptical-character-recognitionpdf
Merge branch 'dev' into feature-bulk-edit
jonaswinkler8699b6931cfc
diff --cc src-ui/src/app/services/rest/document.service.tsindex 07e69c87a,5bf2308d4..0a9160528--- a/src-ui/src/app/services/rest/document.service.ts+++ b/src-ui/src/app/services/rest/document.service.ts@@@ -66,12 -97,8 +97,16 @@@ export class DocumentService extends Abreturn this.http.post(this.getResourceUrl(null, 'post_document'), formData)}+ getMetadata(id: number): Observable<PaperlessDocumentMetadata> {+ return this.http.get<PaperlessDocumentMetadata>(this.getResourceUrl(id, 'metadata'))+ }++ bulk_edit(ids: number[], method: string, args: any[]) {+ return this.http.post(this.getResourceUrl(null, 'bulk_edit'), {+ 'ids': ids,+ 'method': method,+ 'args': args+ })+ }+}diff --cc src/documents/views.pyindex 95448ad62,adef757ef..219cc61b7--- a/src/documents/views.py+++ b/src/documents/views.py@@@ -131,36 -134,32 +139,39 @@@ class DocumentViewSet(RetrieveModelMixiindex.remove_document_from_index(self.get_object())return super(DocumentViewSet, self).destroy(request, *args, **kwargs)- def file_response(self, pk, disposition):- doc = Document.objects.get(id=pk)+ @staticmethod+ def original_requested(request):+ return (+ 'original' in request.query_params and+ request.query_params['original'] == 'true'+ )- if doc.storage_type == Document.STORAGE_TYPE_UNENCRYPTED:- file_handle = doc.source_file+ def file_response(self, pk, request, disposition):+ doc = Document.objects.get(id=pk)+ if not self.original_requested(request) and os.path.isfile(doc.archive_path): # NOQA: E501+ file_handle = doc.archive_file+ filename = doc.archive_file_name+ mime_type = 'application/pdf'else:- file_handle = GnuPG.decrypted(doc.source_file)+ file_handle = doc.source_file+ filename = doc.file_name+ mime_type = doc.mime_type- response = HttpResponse(file_handle, content_type=doc.mime_type)+ if doc.storage_type == Document.STORAGE_TYPE_GPG:+ file_handle = GnuPG.decrypted(file_handle)++ 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)- def post_document(self, request, pk=None):- # TODO: is this a good implementation?- form = UploadForm(data=request.POST, files=request.FILES)- if form.is_valid():- form.save()- return Response("OK")- else:- return HttpResponseBadRequest(str(form.errors))-+ @action(methods=['post'], detail=False)+ def bulk_edit(self, request, pk=None):+ try:+ return Response(perform_bulk_edit(request.data))+ except Exception as e:+ return HttpResponseBadRequest(str(e))+@action(methods=['get'], detail=True)def metadata(self, request, pk=None):try: