Fix to study group distance and radius

This commit is contained in:
Keannu Bernasol 2023-12-19 19:03:16 +08:00
parent 8c13732933
commit 20debf7d45
2 changed files with 2 additions and 5 deletions

View file

@ -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

View file

@ -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