From 734a9b4fe1760913ad4639a9abc0c1c0afc78e2d Mon Sep 17 00:00:00 2001 From: Obdulia Losantos Date: Wed, 6 Oct 2021 10:55:18 +0200 Subject: [PATCH] fix(serializers): use input for related fields (#966) --- aether-kernel/aether/kernel/api/serializers.py | 15 +++++++++++++++ aether-odk-module/aether/odk/api/serializers.py | 2 ++ aether-ui/aether/ui/api/serializers.py | 3 ++- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/aether-kernel/aether/kernel/api/serializers.py b/aether-kernel/aether/kernel/api/serializers.py index a6a698437..6911f85d8 100644 --- a/aether-kernel/aether/kernel/api/serializers.py +++ b/aether-kernel/aether/kernel/api/serializers.py @@ -125,6 +125,7 @@ class MappingSetSerializer(DynamicFieldsMixin, DynamicFieldsModelSerializer): project = MtPrimaryKeyRelatedField( queryset=models.Project.objects.all(), + style={'base_template': 'input.html'}, ) class Meta: @@ -150,10 +151,12 @@ class MappingSerializer(DynamicFieldsMixin, DynamicFieldsModelSerializer): project = MtPrimaryKeyRelatedField( queryset=models.Project.objects.all(), required=False, + style={'base_template': 'input.html'}, ) mappingset = MtPrimaryKeyRelatedField( queryset=models.MappingSet.objects.all(), mt_field='project', + style={'base_template': 'input.html'}, ) class Meta: @@ -177,6 +180,7 @@ class AttachmentSerializer(DynamicFieldsMixin, DynamicFieldsModelSerializer): submission = MtPrimaryKeyRelatedField( queryset=models.Submission.objects.all(), mt_field='project', + style={'base_template': 'input.html'}, ) class Meta: @@ -237,6 +241,11 @@ class SchemaDecoratorSerializer(DynamicFieldsMixin, DynamicFieldsModelSerializer project = MtPrimaryKeyRelatedField( queryset=models.Project.objects.all(), + style={'base_template': 'input.html'}, + ) + schema = serializers.PrimaryKeyRelatedField( + queryset=models.Schema.objects.all(), + style={'base_template': 'input.html'} ) class Meta: @@ -323,21 +332,25 @@ class EntitySerializer(DynamicFieldsMixin, KernelBaseSerializer): project = MtPrimaryKeyRelatedField( queryset=models.Project.objects.all(), required=False, + style={'base_template': 'input.html'}, ) submission = MtPrimaryKeyRelatedField( queryset=models.Submission.objects.all(), mt_field='mappingset__project', required=False, + style={'base_template': 'input.html'}, ) mapping = MtPrimaryKeyRelatedField( queryset=models.Mapping.objects.all(), mt_field='mappingset__project', required=False, + style={'base_template': 'input.html'}, ) schemadecorator = MtPrimaryKeyRelatedField( queryset=models.SchemaDecorator.objects.all(), mt_field='project', required=False, + style={'base_template': 'input.html'}, ) def create(self, validated_data): @@ -474,6 +487,7 @@ class SubmissionSerializer(DynamicFieldsMixin, KernelBaseSerializer): project = MtPrimaryKeyRelatedField( queryset=models.Project.objects.all(), required=False, + style={'base_template': 'input.html'}, ) is_extracted = serializers.BooleanField(default=False) @@ -482,6 +496,7 @@ class SubmissionSerializer(DynamicFieldsMixin, KernelBaseSerializer): queryset=models.MappingSet.objects.all(), mt_field='project', required=False, + style={'base_template': 'input.html'}, ) def create(self, validated_data): diff --git a/aether-odk-module/aether/odk/api/serializers.py b/aether-odk-module/aether/odk/api/serializers.py index 664cfaa1c..f62269f0e 100644 --- a/aether-odk-module/aether/odk/api/serializers.py +++ b/aether-odk-module/aether/odk/api/serializers.py @@ -50,6 +50,7 @@ class MediaFileSerializer(DynamicFieldsMixin, DynamicFieldsModelSerializer): xform = MtPrimaryKeyRelatedField( queryset=XForm.objects.all(), mt_field='project', + style={'base_template': 'input.html'}, ) class Meta: @@ -92,6 +93,7 @@ class XFormSerializer(DynamicFieldsMixin, DynamicFieldsModelSerializer): project = MtPrimaryKeyRelatedField( queryset=Project.objects.all(), + style={'base_template': 'input.html'}, ) def validate(self, value): diff --git a/aether-ui/aether/ui/api/serializers.py b/aether-ui/aether/ui/api/serializers.py index c5a0cab3f..06eff5288 100644 --- a/aether-ui/aether/ui/api/serializers.py +++ b/aether-ui/aether/ui/api/serializers.py @@ -63,8 +63,9 @@ class PipelineSerializer(DynamicFieldsMixin, DynamicFieldsModelSerializer): is_read_only = serializers.BooleanField(read_only=True) project = MtPrimaryKeyRelatedField( - required=False, queryset=models.Project.objects.all(), + required=False, + style={'base_template': 'input.html'}, ) def create(self, validated_data):