From f5df9108945cdcfe0c095bcb64903b9269adad2f Mon Sep 17 00:00:00 2001 From: jonaswinkler Date: Fri, 11 Dec 2020 23:34:24 +0100 Subject: [PATCH] document list validation. --- src/documents/serialisers.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/documents/serialisers.py b/src/documents/serialisers.py index 5418ec0fb..92fc35719 100644 --- a/src/documents/serialisers.py +++ b/src/documents/serialisers.py @@ -185,6 +185,13 @@ class BulkEditSerializer(serializers.Serializer): parameters = serializers.DictField(allow_empty=True) + def validate_documents(self, documents): + count = Document.objects.filter(id__in=documents).count() + if not count == len(documents): + raise serializers.ValidationError( + "Some documents don't exist or were specified twice.") + return documents + def validate_method(self, method): if method == "set_correspondent": return bulk_edit.set_correspondent