mirror of
https://github.com/seanmorley15/AdventureLog.git
synced 2025-07-21 22:09:36 +02:00
Add display_name to ReverseGeocode response and update AdventureModal
This commit is contained in:
parent
25ed72afbc
commit
a7a49227c4
4 changed files with 31 additions and 15 deletions
|
@ -1084,19 +1084,39 @@ class ReverseGeocodeViewSet(viewsets.ViewSet):
|
||||||
Returns a dictionary containing the region name, country name, and ISO code if found.
|
Returns a dictionary containing the region name, country name, and ISO code if found.
|
||||||
"""
|
"""
|
||||||
iso_code = None
|
iso_code = None
|
||||||
|
town = None
|
||||||
|
city = None
|
||||||
|
county = None
|
||||||
|
display_name = None
|
||||||
|
country_code = None
|
||||||
if 'address' in data.keys():
|
if 'address' in data.keys():
|
||||||
keys = data['address'].keys()
|
keys = data['address'].keys()
|
||||||
for key in keys:
|
for key in keys:
|
||||||
if key.find("ISO") != -1:
|
if key.find("ISO") != -1:
|
||||||
iso_code = data['address'][key]
|
iso_code = data['address'][key]
|
||||||
|
if 'town' in keys:
|
||||||
|
town = data['address']['town']
|
||||||
|
if 'county' in keys:
|
||||||
|
county = data['address']['county']
|
||||||
|
if 'city' in keys:
|
||||||
|
city = data['address']['city']
|
||||||
print(iso_code)
|
print(iso_code)
|
||||||
region = Region.objects.filter(id=iso_code).first()
|
region = Region.objects.filter(id=iso_code).first()
|
||||||
visited_region = VisitedRegion.objects.filter(region=region).first()
|
visited_region = VisitedRegion.objects.filter(region=region).first()
|
||||||
is_visited = False
|
is_visited = False
|
||||||
|
country_code = iso_code[:2]
|
||||||
|
|
||||||
|
if city:
|
||||||
|
display_name = f"{city}, {region.name}, {country_code}"
|
||||||
|
elif town and region.name:
|
||||||
|
display_name = f"{town}, {region.name}, {country_code}"
|
||||||
|
elif county and region.name:
|
||||||
|
display_name = f"{county}, {region.name}, {country_code}"
|
||||||
|
|
||||||
if visited_region:
|
if visited_region:
|
||||||
is_visited = True
|
is_visited = True
|
||||||
if region:
|
if region:
|
||||||
return {"id": iso_code, "region": region.name, "country": region.country.name, "is_visited": is_visited}
|
return {"id": iso_code, "region": region.name, "country": region.country.name, "is_visited": is_visited, "display_name": display_name}
|
||||||
return {"error": "No region found"}
|
return {"error": "No region found"}
|
||||||
|
|
||||||
@action(detail=False, methods=['get'])
|
@action(detail=False, methods=['get'])
|
||||||
|
|
|
@ -43,20 +43,6 @@ services:
|
||||||
- "traefik.http.routers.adventurelog.tls=true"
|
- "traefik.http.routers.adventurelog.tls=true"
|
||||||
- "traefik.http.routers.adventurelog.tls.certresolver=letsencrypt"
|
- "traefik.http.routers.adventurelog.tls.certresolver=letsencrypt"
|
||||||
|
|
||||||
nginx:
|
|
||||||
image: nginx:latest
|
|
||||||
restart: unless-stopped
|
|
||||||
labels:
|
|
||||||
- "traefik.enable=true"
|
|
||||||
- "traefik.http.routers.nginx.entrypoints=websecure"
|
|
||||||
- "traefik.http.routers.nginx.rule=Host(`yourdomain.com`) && PathPrefix(`/media`)" # Replace with your domain
|
|
||||||
- "traefik.http.routers.nginx.tls=true"
|
|
||||||
- "traefik.http.routers.nginx.tls.certresolver=letsencrypt"
|
|
||||||
- "traefik.http.middlewares.nginx-stripprefix.stripprefix.prefixes=/media"
|
|
||||||
- "traefik.http.routers.nginx.middlewares=nginx-stripprefix"
|
|
||||||
volumes:
|
|
||||||
- adventurelog-media:/usr/share/nginx/html
|
|
||||||
|
|
||||||
server:
|
server:
|
||||||
image: ghcr.io/seanmorley15/adventurelog-backend:latest
|
image: ghcr.io/seanmorley15/adventurelog-backend:latest
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
|
|
@ -111,6 +111,15 @@
|
||||||
markers = [];
|
markers = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$: {
|
||||||
|
if (
|
||||||
|
reverseGeocodePlace?.display_name &&
|
||||||
|
adventure.location != reverseGeocodePlace.display_name
|
||||||
|
) {
|
||||||
|
adventure.location = reverseGeocodePlace.display_name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let imageSearch: string = adventure.name || '';
|
let imageSearch: string = adventure.name || '';
|
||||||
|
|
||||||
async function removeImage(id: string) {
|
async function removeImage(id: string) {
|
||||||
|
|
|
@ -175,4 +175,5 @@ export type ReverseGeocode = {
|
||||||
region: string;
|
region: string;
|
||||||
country: string;
|
country: string;
|
||||||
is_visited: boolean;
|
is_visited: boolean;
|
||||||
|
display_name: string;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue