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):
|
def longitude(self):
|
||||||
return self.coordinates.x
|
return self.coordinates.x
|
||||||
|
|
||||||
@property
|
|
||||||
def location(self):
|
|
||||||
return self.location_field_indexing
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def location_field_indexing(self):
|
def location_field_indexing(self):
|
||||||
return {'lat': self.latitude,
|
return {'lat': self.latitude,
|
||||||
|
|
|
||||||
|
|
@ -90,9 +90,8 @@ class AddressSerializer(serializers.ModelSerializer):
|
||||||
source='city',
|
source='city',
|
||||||
queryset=models.City.objects.all())
|
queryset=models.City.objects.all())
|
||||||
city = CitySerializer(read_only=True)
|
city = CitySerializer(read_only=True)
|
||||||
geo_lon = serializers.FloatField(allow_null=True, write_only=True)
|
geo_lon = serializers.FloatField(allow_null=True)
|
||||||
geo_lat = serializers.FloatField(allow_null=True, write_only=True)
|
geo_lat = serializers.FloatField(allow_null=True)
|
||||||
location = serializers.ReadOnlyField()
|
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = models.Address
|
model = models.Address
|
||||||
|
|
@ -105,8 +104,7 @@ class AddressSerializer(serializers.ModelSerializer):
|
||||||
'number',
|
'number',
|
||||||
'postal_code',
|
'postal_code',
|
||||||
'geo_lon',
|
'geo_lon',
|
||||||
'geo_lat',
|
'geo_lat'
|
||||||
'location',
|
|
||||||
]
|
]
|
||||||
|
|
||||||
def validate(self, attrs):
|
def validate(self, attrs):
|
||||||
|
|
@ -121,10 +119,12 @@ class AddressSerializer(serializers.ModelSerializer):
|
||||||
|
|
||||||
def to_representation(self, instance):
|
def to_representation(self, instance):
|
||||||
"""Override to_representation method"""
|
"""Override to_representation method"""
|
||||||
if not instance.coordinates or not isinstance(instance.coordinates, Point):
|
if instance.coordinates and isinstance(instance.coordinates, Point):
|
||||||
setattr(instance, 'location', {
|
# Point(longitude, latitude)
|
||||||
'lat': float(0),
|
setattr(instance, 'geo_lat', instance.coordinates.x)
|
||||||
'lon': float(0),
|
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)
|
return super().to_representation(instance)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,7 @@ class EstablishmentDocumentSerializer(DocumentSerializer):
|
||||||
fields = (
|
fields = (
|
||||||
'id',
|
'id',
|
||||||
'name',
|
'name',
|
||||||
# 'description',
|
'description',
|
||||||
'public_mark',
|
'public_mark',
|
||||||
'toque_number',
|
'toque_number',
|
||||||
'price_level',
|
'price_level',
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user