|
1 | | -from decimal import ROUND_DOWN, Decimal |
2 | 1 |
|
3 | 2 | from django.contrib.auth import get_user_model |
4 | 3 | from django.core.exceptions import ValidationError as ModelValidationError |
@@ -110,12 +109,12 @@ class Meta: |
110 | 109 |
|
111 | 110 | def get_latitude(self, obj): |
112 | 111 | if obj.approximate_latitude: |
113 | | - return round(float(obj.approximate_latitude), 6) |
| 112 | + return float(obj.approximate_latitude) |
114 | 113 | return None |
115 | 114 |
|
116 | 115 | def get_longitude(self, obj): |
117 | 116 | if obj.approximate_longitude: |
118 | | - return round(float(obj.approximate_longitude), 6) |
| 117 | + return float(obj.approximate_longitude) |
119 | 118 | return None |
120 | 119 |
|
121 | 120 | # Unified serializer for all listing types (Items and Sublets); used for CRUD operations |
@@ -277,11 +276,9 @@ def _create_sublet(self, validated_data, additional_data): |
277 | 276 |
|
278 | 277 |
|
279 | 278 | if latitude is not None: |
280 | | - latitude = Decimal(str(latitude)).quantize( |
281 | | - Decimal("0.000001"), rounding=ROUND_DOWN) |
| 279 | + latitude = float(latitude) |
282 | 280 | if longitude is not None: |
283 | | - longitude = Decimal(str(longitude)).quantize( |
284 | | - Decimal("0.000001"), rounding=ROUND_DOWN) |
| 281 | + longitude = float(longitude) |
285 | 282 |
|
286 | 283 | sublet = Sublet.objects.create( |
287 | 284 | street_address=additional_data.get("street_address"), |
@@ -348,15 +345,9 @@ def _update_sublet(self, instance, additional_data): |
348 | 345 | if field in additional_data: |
349 | 346 | setattr(sublet, field, additional_data[field]) |
350 | 347 | if "latitude" in additional_data: |
351 | | - latitude = Decimal(str(additional_data["latitude"])).quantize( |
352 | | - Decimal("0.000001"), rounding=ROUND_DOWN |
353 | | - ) |
354 | | - sublet.latitude = latitude |
| 348 | + sublet.latitude = float(additional_data["latitude"]) |
355 | 349 | if "longitude" in additional_data: |
356 | | - longitude = Decimal(str(additional_data["longitude"])).quantize( |
357 | | - Decimal("0.000001"), rounding=ROUND_DOWN |
358 | | - ) |
359 | | - sublet.longitude = longitude |
| 350 | + sublet.longitude = float(additional_data["longitude"]) |
360 | 351 | sublet.full_clean() |
361 | 352 | sublet.save() |
362 | 353 |
|
|
0 commit comments