From 9902c0fc14540d293890608f771839953f08ae3f Mon Sep 17 00:00:00 2001 From: Keannu Bernasol Date: Mon, 7 Aug 2023 15:36:37 +0800 Subject: [PATCH] Improved student status serializer --- stude/student_status/serializers.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/stude/student_status/serializers.py b/stude/student_status/serializers.py index 579b1f8..b1b201c 100644 --- a/stude/student_status/serializers.py +++ b/stude/student_status/serializers.py @@ -13,6 +13,7 @@ class StudentStatusSerializer(serializers.ModelSerializer): location = PointField(required=True) landmark = serializers.SlugRelatedField( queryset=Landmark.objects.all(), many=False, slug_field='name', required=False, allow_null=True) + active = serializers.BooleanField(required=True) class Meta: model = StudentStatus @@ -30,10 +31,6 @@ class StudentStatusSerializer(serializers.ModelSerializer): active = validated_data.get('active', None) subject = validated_data.get('subject', None) - # Do not update if instance if active is not specified - if active is None: - return instance - # If status is set as inactive or if no subject is specified in the request, clear the student status if active is not None and active is False or not subject: validated_data['location'] = Point(0, 0)