From b46dbb5c8279b3df9cecdde50c3c805e47f67e13 Mon Sep 17 00:00:00 2001 From: mortezaei Date: Sun, 28 Dec 2025 13:58:26 +0330 Subject: [PATCH] s --- apps/account/serializers/location_history.py | 14 +++++++++++++- apps/account/views/location_history.py | 2 +- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/apps/account/serializers/location_history.py b/apps/account/serializers/location_history.py index 0aad9b2..907eed6 100644 --- a/apps/account/serializers/location_history.py +++ b/apps/account/serializers/location_history.py @@ -22,4 +22,16 @@ class ReverseGeolocationSerializer(serializers.Serializer): min_value=-180.0, max_value=180.0, help_text="Longitude coordinate (-180 to 180)" - ) \ No newline at end of file + ) + + +class ReverseGeolocationResponseSerializer(serializers.Serializer): + """Serializer for reverse geolocation response""" + latitude = serializers.FloatField(read_only=True) + longitude = serializers.FloatField(read_only=True) + city = serializers.CharField(max_length=100, allow_null=True, read_only=True) + country = serializers.CharField(max_length=100, allow_null=True, read_only=True) + country_code = serializers.CharField(max_length=10, allow_null=True, read_only=True) + accuracy_radius = serializers.IntegerField(allow_null=True, read_only=True, required=False) + time_zone = serializers.CharField(max_length=100, allow_null=True, allow_blank=True, read_only=True, required=False) + postal_code = serializers.CharField(max_length=20, allow_null=True, allow_blank=True, read_only=True, required=False) \ No newline at end of file diff --git a/apps/account/views/location_history.py b/apps/account/views/location_history.py index 971cbd6..e997649 100644 --- a/apps/account/views/location_history.py +++ b/apps/account/views/location_history.py @@ -9,7 +9,7 @@ from rest_framework.response import Response from rest_framework.views import APIView from rest_framework import status from apps.account.models import LocationHistory -from apps.account.serializers import LocationHistorySerializer, ReverseGeolocationSerializer +from apps.account.serializers import LocationHistorySerializer, ReverseGeolocationSerializer, ReverseGeolocationResponseSerializer import geoip2.database import geoip2.errors from city_detection_ip import get_location_by_coordinates, get_location_by_ip, SPECIAL_COORDINATES