1
0
Fork 0
mirror of https://github.com/seanmorley15/AdventureLog.git synced 2025-07-25 07:49:37 +02:00

feat: Add location_name to ReverseGeocode type and implement location fetching in stats view

This commit is contained in:
Sean Morley 2025-02-15 19:44:11 -05:00
parent 60b5bbb3c8
commit b5d6788c11
21 changed files with 1048 additions and 901 deletions

View file

@ -21,10 +21,14 @@ class ReverseGeocodeViewSet(viewsets.ViewSet):
country_code = None
city = None
visited_city = None
location_name = None
# town = None
# city = None
# county = None
if 'name' in data.keys():
location_name = data['name']
if 'address' in data.keys():
keys = data['address'].keys()
@ -58,7 +62,7 @@ class ReverseGeocodeViewSet(viewsets.ViewSet):
if visited_city:
city_visited = True
if region:
return {"region_id": iso_code, "region": region.name, "country": region.country.name, "region_visited": region_visited, "display_name": display_name, "city": city.name if city else None, "city_id": city.id if city else None, "city_visited": city_visited}
return {"region_id": iso_code, "region": region.name, "country": region.country.name, "region_visited": region_visited, "display_name": display_name, "city": city.name if city else None, "city_id": city.id if city else None, "city_visited": city_visited, 'location_name': location_name}
return {"error": "No region found"}
@action(detail=False, methods=['get'])

View file

@ -48,4 +48,11 @@ class StatsViewSet(viewsets.ViewSet):
'total_regions': total_regions,
'visited_country_count': visited_country_count,
'total_countries': total_countries
})
})
# locations - returns a list of all of the latitude, longitude locations of all public adventrues on the server
@action(detail=False, methods=['get'], url_path='locations')
def locations(self, request):
adventures = Adventure.objects.filter(
is_public=True).values('latitude', 'longitude', 'id', 'name')
return Response(adventures)