From 9f0815ad298706d38757141a28d4badbc94d6ff1 Mon Sep 17 00:00:00 2001 From: jh-RLI Date: Mon, 21 Oct 2024 23:52:28 +0200 Subject: [PATCH] add base serializer for scenario dataset post payload #1890 --- api/serializers.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/api/serializers.py b/api/serializers.py index 0f80d4faa..eb5a2110f 100644 --- a/api/serializers.py +++ b/api/serializers.py @@ -53,3 +53,18 @@ class Meta: model = Table # fields = ["id", "model_name", "acronym", "url"] fields = ["id", "name", "human_readable_name", "url"] + + +class ScenarioBundleScenarioDatasetSerializer(serializers.Serializer): + scenario = serializers.UUIDField(required=True) # Validate the scenario UUID + dataset = serializers.ListField( + child=serializers.CharField(max_length=255), required=True + ) # List of dataset table names + type = serializers.ChoiceField( + choices=["input", "output"], required=True + ) # Type: input or output + + def __getitem__(self, items): + print(type(items), items) + if items is None: + return None