Hotfix for study groups distance

This commit is contained in:
Keannu Bernasol 2023-12-19 18:50:00 +08:00
parent d1244296f8
commit dda6b62f37

View file

@ -70,6 +70,11 @@ class StudyGroupDistanceSerializer(serializers.ModelSerializer):
fields = '__all__' fields = '__all__'
read_only_fields = ['landmark', 'radius', 'students', 'distance'] read_only_fields = ['landmark', 'radius', 'students', 'distance']
def get_distance(self, obj):
if hasattr(obj, 'distance'):
return obj.distance.km
return 0
def to_representation(self, instance): def to_representation(self, instance):
representation = super().to_representation(instance) representation = super().to_representation(instance)
representation['distance'] = 30 representation['distance'] = 30