fixed for fix of geo data in track_user view
This commit is contained in:
@@ -116,7 +116,7 @@ class TrackUserViewTest(APITestCase):
|
||||
'model': 'company',
|
||||
'id': company.id,
|
||||
},
|
||||
'geo': (12.2, -0.545)
|
||||
'geo': {'latitude': 12.2, 'longitude': -0.545}
|
||||
}
|
||||
|
||||
# Query endpoint
|
||||
|
||||
@@ -51,6 +51,12 @@ def track_user(request):
|
||||
"""
|
||||
try:
|
||||
data = json.loads(request.body)
|
||||
# import ipdb; ipdb.set_trace()
|
||||
|
||||
if data.get('geo'):
|
||||
coordinates = (data['geo'].get('latitude'), data['geo'].get('longitude'))
|
||||
else:
|
||||
coordinates = None
|
||||
|
||||
# gather instance data
|
||||
instance_data = {
|
||||
@@ -58,7 +64,7 @@ def track_user(request):
|
||||
'user': None if request.user.is_anonymous else request.user,
|
||||
'anonymous': request.user.is_anonymous,
|
||||
'ip_address': data.get('ip'),
|
||||
'geo': Point(data.get('geo')['latitude'], data.get('geo')['longitude']),
|
||||
'geo': Point(coordinates),
|
||||
}
|
||||
|
||||
if data['action_object'].get('model') == 'product':
|
||||
@@ -76,4 +82,4 @@ def track_user(request):
|
||||
return Response(status=status.HTTP_201_CREATED)
|
||||
except Exception as e:
|
||||
logging.error(f"Stats could not be created: {str(e)}")
|
||||
return Response(f"Process could not be registered: {str(type(e))}", status=status.HTTP_406_NOT_ACCEPTABLE)
|
||||
return Response(f"Process could not be registered [{str(type(e))}]: {str(e)}", status=status.HTTP_406_NOT_ACCEPTABLE)
|
||||
|
||||
Reference in New Issue
Block a user