mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-12-09 00:05:21 +01:00
Enhancement: add storage_path parameter to post_document API (#5217)
* Feature: add `storage_path` parameter to post_document API * Complete coverage for validate_storage_path --------- Co-authored-by: shamoon <4887959+shamoon@users.noreply.github.com>
This commit is contained in:
parent
3b6ce16f1c
commit
bbf64b7e93
4 changed files with 67 additions and 1 deletions
|
|
@ -966,6 +966,14 @@ class PostDocumentSerializer(serializers.Serializer):
|
|||
required=False,
|
||||
)
|
||||
|
||||
storage_path = serializers.PrimaryKeyRelatedField(
|
||||
queryset=StoragePath.objects.all(),
|
||||
label="Storage path",
|
||||
allow_null=True,
|
||||
write_only=True,
|
||||
required=False,
|
||||
)
|
||||
|
||||
tags = serializers.PrimaryKeyRelatedField(
|
||||
many=True,
|
||||
queryset=Tag.objects.all(),
|
||||
|
|
@ -1005,6 +1013,12 @@ class PostDocumentSerializer(serializers.Serializer):
|
|||
else:
|
||||
return None
|
||||
|
||||
def validate_storage_path(self, storage_path):
|
||||
if storage_path:
|
||||
return storage_path.id
|
||||
else:
|
||||
return None
|
||||
|
||||
def validate_tags(self, tags):
|
||||
if tags:
|
||||
return [tag.id for tag in tags]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue