mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-08-24 01:06:17 +00: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:
@@ -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]
|
||||
|
Reference in New Issue
Block a user