mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-08-12 00:19:48 +00:00
Creates a data model for the document consumption, allowing stronger typing of arguments and setting of some information about the file only once
This commit is contained in:
@@ -5,7 +5,6 @@ import os
|
||||
import re
|
||||
import tempfile
|
||||
import urllib
|
||||
import uuid
|
||||
import zipfile
|
||||
from datetime import datetime
|
||||
from pathlib import Path
|
||||
@@ -65,6 +64,9 @@ from .bulk_download import ArchiveOnlyStrategy
|
||||
from .bulk_download import OriginalAndArchiveStrategy
|
||||
from .bulk_download import OriginalsOnlyStrategy
|
||||
from .classifier import load_classifier
|
||||
from .data_models import ConsumableDocument
|
||||
from .data_models import DocumentMetadataOverrides
|
||||
from .data_models import DocumentSource
|
||||
from .filters import CorrespondentFilterSet
|
||||
from .filters import DocumentFilterSet
|
||||
from .filters import DocumentTypeFilterSet
|
||||
@@ -692,19 +694,24 @@ class PostDocumentView(GenericAPIView):
|
||||
|
||||
os.utime(temp_file_path, times=(t, t))
|
||||
|
||||
task_id = str(uuid.uuid4())
|
||||
input_doc = ConsumableDocument(
|
||||
source=DocumentSource.ApiUpload,
|
||||
original_file=temp_file_path,
|
||||
)
|
||||
input_doc_overrides = DocumentMetadataOverrides(
|
||||
filename=doc_name,
|
||||
title=title,
|
||||
correspondent_id=correspondent_id,
|
||||
document_type_id=document_type_id,
|
||||
tag_ids=tag_ids,
|
||||
created=created,
|
||||
asn=archive_serial_number,
|
||||
owner_id=request.user.id,
|
||||
)
|
||||
|
||||
async_task = consume_file.delay(
|
||||
# Paths are not JSON friendly
|
||||
str(temp_file_path),
|
||||
override_title=title,
|
||||
override_correspondent_id=correspondent_id,
|
||||
override_document_type_id=document_type_id,
|
||||
override_tag_ids=tag_ids,
|
||||
task_id=task_id,
|
||||
override_created=created,
|
||||
override_owner_id=request.user.id,
|
||||
override_archive_serial_num=archive_serial_number,
|
||||
input_doc,
|
||||
input_doc_overrides,
|
||||
)
|
||||
|
||||
return Response(async_task.id)
|
||||
|
Reference in New Issue
Block a user