Revert "address coordinates in get api queries"
This reverts commit f21b400
This commit is contained in:
parent
2fe0ce86d3
commit
e0d09486c2
|
|
@ -104,10 +104,6 @@ class Address(models.Model):
|
|||
def longitude(self):
|
||||
return self.coordinates.x
|
||||
|
||||
@property
|
||||
def location(self):
|
||||
return self.location_field_indexing
|
||||
|
||||
@property
|
||||
def location_field_indexing(self):
|
||||
return {'lat': self.latitude,
|
||||
|
|
|
|||
|
|
@ -90,9 +90,8 @@ class AddressSerializer(serializers.ModelSerializer):
|
|||
source='city',
|
||||
queryset=models.City.objects.all())
|
||||
city = CitySerializer(read_only=True)
|
||||
geo_lon = serializers.FloatField(allow_null=True, write_only=True)
|
||||
geo_lat = serializers.FloatField(allow_null=True, write_only=True)
|
||||
location = serializers.ReadOnlyField()
|
||||
geo_lon = serializers.FloatField(allow_null=True)
|
||||
geo_lat = serializers.FloatField(allow_null=True)
|
||||
|
||||
class Meta:
|
||||
model = models.Address
|
||||
|
|
@ -105,8 +104,7 @@ class AddressSerializer(serializers.ModelSerializer):
|
|||
'number',
|
||||
'postal_code',
|
||||
'geo_lon',
|
||||
'geo_lat',
|
||||
'location',
|
||||
'geo_lat'
|
||||
]
|
||||
|
||||
def validate(self, attrs):
|
||||
|
|
@ -121,10 +119,12 @@ class AddressSerializer(serializers.ModelSerializer):
|
|||
|
||||
def to_representation(self, instance):
|
||||
"""Override to_representation method"""
|
||||
if not instance.coordinates or not isinstance(instance.coordinates, Point):
|
||||
setattr(instance, 'location', {
|
||||
'lat': float(0),
|
||||
'lon': float(0),
|
||||
})
|
||||
if instance.coordinates and isinstance(instance.coordinates, Point):
|
||||
# Point(longitude, latitude)
|
||||
setattr(instance, 'geo_lat', instance.coordinates.x)
|
||||
setattr(instance, 'geo_lon', instance.coordinates.y)
|
||||
else:
|
||||
setattr(instance, 'geo_lat', float(0))
|
||||
setattr(instance, 'geo_lon', float(0))
|
||||
return super().to_representation(instance)
|
||||
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ class EstablishmentDocumentSerializer(DocumentSerializer):
|
|||
fields = (
|
||||
'id',
|
||||
'name',
|
||||
# 'description',
|
||||
'description',
|
||||
'public_mark',
|
||||
'toque_number',
|
||||
'price_level',
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user