Document uploads should be owned by user

This commit is contained in:
Michael Shamoon
2022-12-12 13:24:59 -08:00
parent 8159b7574c
commit 446842ecfc
5 changed files with 31 additions and 1 deletions

View File

@@ -681,6 +681,14 @@ class PostDocumentSerializer(serializers.Serializer):
required=False,
)
owner = serializers.PrimaryKeyRelatedField(
queryset=User.objects.all(),
label="Owner",
allow_null=True,
write_only=True,
required=False,
)
def validate_document(self, document):
document_data = document.file.read()
mime_type = magic.from_buffer(document_data, mime=True)
@@ -710,6 +718,12 @@ class PostDocumentSerializer(serializers.Serializer):
else:
return None
def validate_owner(self, owner):
if owner:
return owner.id
else:
return None
class BulkDownloadSerializer(DocumentListSerializer):