Skip to content

Commit 489095b

Browse files
committed
Add location_json field for location coordinate
1 parent 55f3dfa commit 489095b

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

local_units/models.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,15 @@ def __str__(self):
360360
branch_name = self.local_branch_name or self.english_branch_name
361361
return f"{branch_name} ({self.country.name})"
362362

363+
def location_json(self):
364+
"""
365+
Returns location in JSON format
366+
"""
367+
return {
368+
"lat": self.location.y,
369+
"lng": self.location.x,
370+
}
371+
363372

364373
class LocalUnitChangeRequest(models.Model):
365374

local_units/views.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,11 @@ def update(self, request, *args, **kwargs):
9494
# Creating a new change request for the local unit
9595
LocalUnitChangeRequest.objects.create(
9696
local_unit=local_unit,
97-
previous_data=serializer,
97+
previous_data=serializer.data,
9898
status=LocalUnitChangeRequest.Status.PENDING,
9999
triggered_by=request.user,
100100
)
101-
return response.Response(serializer)
101+
return response.Response(serializer.data)
102102

103103
@extend_schema(request=None, responses=PrivateLocalUnitSerializer)
104104
@action(

0 commit comments

Comments
 (0)