Added a dummy endpoint with no functionality to the API
This commit is contained in:
1 parent
ed478a1d73
commit
4cc6bf889e
3 files changed
+112
-2
No files matched your search
@@ -398,3 +398,79 @@ class SelectionDataSerializer(serializers.Serializer):
|
||||
required=True,
|
||||
child=serializers.IntegerField()
|
||||
)
|
||||
|
||||
|
||||
class DocumentSplitMergePlanSerializer(serializers.Serializer):
|
||||
"""
|
||||
A split/merge plan describes how a set of documents should be transformed
|
||||
into a new set of documents.
|
||||
|
||||
split_merge_plan is a list. The split and merge tool will create a new
|
||||
document for each element in that list. Each item in split_merge_plan
|
||||
is by itself a list that lists document IDs and pages to take from this
|
||||
document.
|
||||
|
||||
Example:
|
||||
|
||||
split_merge_plan = [
|
||||
[
|
||||
{
|
||||
"document": 1,
|
||||
"pages": [1,2,3]
|
||||
},
|
||||
{
|
||||
"document": 2,
|
||||
},
|
||||
{
|
||||
"document": 1,
|
||||
"pages": [4]
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
"document": 1,
|
||||
"pages": [6,5]
|
||||
}
|
||||
]
|
||||
]
|
||||
|
||||
This will split document 1 into two documents. The first document contains
|
||||
pages 1 to 4, the second document contains pages 5 and 6 in reverse.
|
||||
Additionally, all pages from document 2 are inserted into the first
|
||||
document between pages 3 and 4.
|
||||
|
||||
If delete_source is true, the split and merge tool will delete the source
|
||||
files in the plan after all resulting documents have been added
|
||||
successfully to paperless.
|
||||
|
||||
metadata selects how to assign new metadata to the created documents.
|
||||
With 'redo', paperless will run the matching algorithms on the resulting
|
||||
document again. With 'copy_first', each document created by the merge plan
|
||||
will keep the metadata of the first document used to create that new
|
||||
document.
|
||||
|
||||
If preview is true, the split and merge tool will execute the split and
|
||||
merge plan without modifying any data in paperless. The previews are
|
||||
temporarily made available for download. If preview is true,
|
||||
delete_source and metadata is ignored.
|
||||
|
||||
"""
|
||||
|
||||
split_merge_plan = serializers.ListField(
|
||||
required=True,
|
||||
min_length=1,
|
||||
child=serializers.ListField(
|
||||
required=True,
|
||||
min_length=0,
|
||||
child=serializers.DictField()
|
||||
)
|
||||
)
|
||||
|
||||
delete_source = serializers.BooleanField(default=False)
|
||||
|
||||
metadata = serializers.ChoiceField(
|
||||
required=True,
|
||||
choices=("redo", "copy_first")
|
||||
)
|
||||
|
||||
preview = serializers.BooleanField(default=False)
|
||||
+30
-1
@@ -52,7 +52,9 @@ from .serialisers import (
|
||||
DocumentTypeSerializer,
|
||||
PostDocumentSerializer,
|
||||
SavedViewSerializer,
|
||||
BulkEditSerializer, SelectionDataSerializer
|
||||
BulkEditSerializer,
|
||||
SelectionDataSerializer,
|
||||
DocumentSplitMergePlanSerializer
|
||||
)
|
||||
|
||||
|
||||
@@ -594,3 +596,30 @@ class StatisticsView(APIView):
|
||||
'documents_inbox': Document.objects.filter(
|
||||
tags__is_inbox_tag=True).distinct().count()
|
||||
})
|
||||
|
||||
|
||||
class DocumentMergeView(APIView):
|
||||
|
||||
permission_classes = (IsAuthenticated,)
|
||||
serializer_class = DocumentSplitMergePlanSerializer
|
||||
parser_classes = (parsers.JSONParser,)
|
||||
|
||||
def get_serializer_context(self):
|
||||
return {
|
||||
'request': self.request,
|
||||
'format': self.format_kwarg,
|
||||
'view': self
|
||||
}
|
||||
|
||||
def get_serializer(self, *args, **kwargs):
|
||||
kwargs['context'] = self.get_serializer_context()
|
||||
return self.serializer_class(*args, **kwargs)
|
||||
|
||||
def post(self, request, *args, **kwargs):
|
||||
serializer = self.get_serializer(data=request.data)
|
||||
serializer.is_valid(raise_exception=True)
|
||||
|
||||
# merge_plan = serializer.validated_data.get("merge_plan")
|
||||
# preview = serializer.validated_data.get("preview")
|
||||
|
||||
return Response("Not implemented yet")
|
||||
@@ -23,7 +23,8 @@ from documents.views import (
|
||||
PostDocumentView,
|
||||
SavedViewViewSet,
|
||||
BulkEditView,
|
||||
SelectionDataView
|
||||
SelectionDataView,
|
||||
DocumentMergeView
|
||||
)
|
||||
from paperless.views import FaviconView
|
||||
|
||||
@@ -63,6 +64,10 @@ urlpatterns = [
|
||||
re_path(r"^documents/selection_data/", SelectionDataView.as_view(),
|
||||
name="selection_data"),
|
||||
|
||||
re_path(r"^documents/merge/",
|
||||
DocumentMergeView.as_view(),
|
||||
name="merge"),
|
||||
|
||||
path('token/', views.obtain_auth_token)
|
||||
|
||||
] + api_router.urls)),
|
||||
|
||||
Reference in new issue
Block a user