From 20debf7d457837256d58bc66583fff06eaf5c6f4 Mon Sep 17 00:00:00 2001 From: Keannu Bernasol Date: Tue, 19 Dec 2023 19:03:16 +0800 Subject: [PATCH] Fix to study group distance and radius --- stude/study_groups/serializers.py | 4 ++-- stude/study_groups/views.py | 3 --- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/stude/study_groups/serializers.py b/stude/study_groups/serializers.py index 9282c51..1c50ce1 100644 --- a/stude/study_groups/serializers.py +++ b/stude/study_groups/serializers.py @@ -62,7 +62,6 @@ class StudyGroupDistanceSerializer(serializers.ModelSerializer): location = PointField() landmark = serializers.SlugRelatedField( queryset=Landmark.objects.all(), many=False, slug_field='name', required=False, allow_null=True) - radius = serializers.FloatField() distance = serializers.SerializerMethodField(default=0) class Meta: @@ -77,7 +76,8 @@ class StudyGroupDistanceSerializer(serializers.ModelSerializer): def to_representation(self, instance): representation = super().to_representation(instance) - representation['distance'] = 10 + representation['distance'] = self.get_distance(instance) + representation['radius'] = 15 return representation diff --git a/stude/study_groups/views.py b/stude/study_groups/views.py index 2ac1632..5f25656 100644 --- a/stude/study_groups/views.py +++ b/stude/study_groups/views.py @@ -120,9 +120,6 @@ class StudyGroupListNearView(generics.ListAPIView): studygroups = StudyGroup.objects.filter(subject__in=user_subjects).annotate( distance=Distance('location', user_location)).filter(distance__lte=100) - for group in studygroups: - # Annotate the group with the radius - group.radius = 30 return studygroups