mirror of
https://github.com/lemeow125/StudE-Backend.git
synced 2024-11-17 06:19:24 +08:00
Improved student status serializer
This commit is contained in:
parent
3df8aed143
commit
9902c0fc14
1 changed files with 1 additions and 4 deletions
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue