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:
Bevan Kay
2024-01-03 19:31:56 +11:00
committed by GitHub
parent 3b6ce16f1c
commit bbf64b7e93
4 changed files with 67 additions and 1 deletions

View File

@@ -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]