diff --git a/backend/server/adventures/geocoding.py b/backend/server/adventures/geocoding.py index 937bd69..aaf3459 100644 --- a/backend/server/adventures/geocoding.py +++ b/backend/server/adventures/geocoding.py @@ -166,7 +166,6 @@ def is_host_resolvable(hostname: str) -> bool: def reverse_geocode(lat, lon, user): if getattr(settings, 'GOOGLE_MAPS_API_KEY', None): - print("Using Google Maps API for reverse geocoding") return reverse_geocode_google(lat, lon, user) return reverse_geocode_osm(lat, lon, user) diff --git a/backend/server/adventures/views/reverse_geocode_view.py b/backend/server/adventures/views/reverse_geocode_view.py index 4689a82..4a5ba26 100644 --- a/backend/server/adventures/views/reverse_geocode_view.py +++ b/backend/server/adventures/views/reverse_geocode_view.py @@ -46,7 +46,7 @@ class ReverseGeocodeViewSet(viewsets.ViewSet): return Response({"error": "An internal error occurred while processing the request"}, status=500) @action(detail=False, methods=['post']) - def mark_visited_region(self, request): + def mark_visited_region(self, _): # searches through all of the users adventures, if the serialized data is_visited, is true, runs reverse geocode on the adventures and if a region is found, marks it as visited. Use the extractIsoCode function to get the region new_region_count = 0 new_regions = {} @@ -60,14 +60,13 @@ class ReverseGeocodeViewSet(viewsets.ViewSet): lon = adventure.longitude if not lat or not lon: continue - url = f"https://nominatim.openstreetmap.org/reverse?format=jsonv2&lat={lat}&lon={lon}" - headers = {'User-Agent': 'AdventureLog Server'} - response = requests.get(url, headers=headers) - try: - data = response.json() - except requests.exceptions.JSONDecodeError: - return Response({"error": "Invalid response from geocoding service"}, status=400) - extracted_region = extractIsoCode(self.request.user,data) + + # Use the existing reverse_geocode function which handles both Google and OSM + data = reverse_geocode(lat, lon, self.request.user) + if 'error' in data: + continue + + extracted_region = extractIsoCode(self.request.user, data) if 'error' not in extracted_region: region = Region.objects.filter(id=extracted_region['region_id']).first() visited_region = VisitedRegion.objects.filter(region=region, user_id=self.request.user).first() diff --git a/backend/server/integrations/views.py b/backend/server/integrations/views.py index dbf383a..f308ddd 100644 --- a/backend/server/integrations/views.py +++ b/backend/server/integrations/views.py @@ -1,13 +1,13 @@ import os from rest_framework.response import Response from rest_framework import viewsets, status - from .serializers import ImmichIntegrationSerializer from .models import ImmichIntegration from rest_framework.decorators import action from rest_framework.permissions import IsAuthenticated import requests from rest_framework.pagination import PageNumberPagination +from django.conf import settings class IntegrationView(viewsets.ViewSet): permission_classes = [IsAuthenticated] @@ -16,15 +16,16 @@ class IntegrationView(viewsets.ViewSet): RESTful GET method for listing all integrations. """ immich_integrations = ImmichIntegration.objects.filter(user=request.user) + google_map_integration = settings.GOOGLE_MAPS_API_KEY is not '' return Response( { - 'immich': immich_integrations.exists() + 'immich': immich_integrations.exists(), + 'google_maps': google_map_integration }, status=status.HTTP_200_OK ) - class StandardResultsSetPagination(PageNumberPagination): page_size = 25 page_size_query_param = 'page_size' diff --git a/backend/server/worldtravel/management/commands/download-countries.py b/backend/server/worldtravel/management/commands/download-countries.py index 60c9173..d4221fa 100644 --- a/backend/server/worldtravel/management/commands/download-countries.py +++ b/backend/server/worldtravel/management/commands/download-countries.py @@ -61,6 +61,7 @@ class Command(BaseCommand): return elif os.path.getsize(countries_json_path) == 0: self.stdout.write(self.style.ERROR('countries+regions+states.json is empty')) + return elif Country.objects.count() == 0 or Region.objects.count() == 0 or City.objects.count() == 0: self.stdout.write(self.style.WARNING('Some region data is missing. Re-importing all data.')) else: diff --git a/frontend/src/lib/components/AboutModal.svelte b/frontend/src/lib/components/AboutModal.svelte index 7b8fbf2..46ad5aa 100644 --- a/frontend/src/lib/components/AboutModal.svelte +++ b/frontend/src/lib/components/AboutModal.svelte @@ -7,11 +7,19 @@ const dispatch = createEventDispatcher(); let modal: HTMLDialogElement; - onMount(() => { + let integrations: Record | null = null; + + onMount(async () => { modal = document.getElementById('about_modal') as HTMLDialogElement; if (modal) { modal.showModal(); } + const response = await fetch('/api/integrations'); + if (response.ok) { + integrations = await response.json(); + } else { + integrations = null; + } }); function close() { @@ -90,18 +98,38 @@

{$t('about.oss_attributions')}

-

- {$t('about.nominatim_1')} - - OpenStreetMap - - . {$t('about.nominatim_2')} -

+ {#if integrations && integrations?.google_maps} +

+ {$t('about.nominatim_1')} + + Google Maps + + . +

+ {:else if integrations && !integrations?.google_maps} +

+ {$t('about.nominatim_1')} + + OpenStreetMap + + . {$t('about.nominatim_2')} +

+ {:else} +

+ {$t('about.generic_attributions')} +

+ {/if} +

{$t('about.other_attributions')}

diff --git a/frontend/src/locales/de.json b/frontend/src/locales/de.json index e5e15e6..3a77025 100644 --- a/frontend/src/locales/de.json +++ b/frontend/src/locales/de.json @@ -8,7 +8,8 @@ "nominatim_2": "Deren Daten sind unter der ODbL-Lizenz lizenziert.", "oss_attributions": "Open Source Quellenangaben", "other_attributions": "Weitere Hinweise finden Sie in der README-Datei.", - "source_code": "Quellcode" + "source_code": "Quellcode", + "generic_attributions": "Melden Sie sich bei Adventurelog an, um Zuschreibungen für aktivierte Integrationen und Dienste anzuzeigen." }, "adventures": { "activities": { @@ -267,7 +268,8 @@ "sun_times": "Sonnenzeiten", "sunrise": "Sonnenaufgang", "sunset": "Sonnenuntergang", - "timed": "Zeitlich abgestimmt" + "timed": "Zeitlich abgestimmt", + "distance": "Distanz" }, "home": { "desc_1": "Entdecken, planen und erkunden Sie mühelos", diff --git a/frontend/src/locales/en.json b/frontend/src/locales/en.json index 68fbe48..8f9ea7a 100644 --- a/frontend/src/locales/en.json +++ b/frontend/src/locales/en.json @@ -42,6 +42,7 @@ "nominatim_1": "Location Search and Geocoding is provided by", "nominatim_2": "Their data is liscensed under the ODbL license.", "other_attributions": "Additional attributions can be found in the README file.", + "generic_attributions": "Login to AdventureLog to view attributions for enabled integrations and services.", "close": "Close" }, "home": { diff --git a/frontend/src/locales/es.json b/frontend/src/locales/es.json index 5d2aa78..a91ef70 100644 --- a/frontend/src/locales/es.json +++ b/frontend/src/locales/es.json @@ -42,7 +42,8 @@ "nominatim_1": "La búsqueda de ubicaciones y geocodificación es proporcionada por", "nominatim_2": "Sus datos están licenciados bajo la licencia ODbL.", "other_attributions": "Atribuciones adicionales se pueden encontrar en el archivo README.", - "close": "Cerrar" + "close": "Cerrar", + "generic_attributions": "Inicie sesión en AdventurElog para ver las atribuciones para integraciones y servicios habilitados." }, "home": { "hero_1": "Descubre las Aventuras Más Emocionantes del Mundo", @@ -315,7 +316,8 @@ "sun_times": "Sol Times", "sunrise": "Amanecer", "sunset": "Atardecer", - "timed": "Cronometrado" + "timed": "Cronometrado", + "distance": "Distancia" }, "worldtravel": { "all": "Todo", diff --git a/frontend/src/locales/fr.json b/frontend/src/locales/fr.json index 1b5c2bd..f35d568 100644 --- a/frontend/src/locales/fr.json +++ b/frontend/src/locales/fr.json @@ -8,7 +8,8 @@ "nominatim_2": "Leurs données sont sous licence ODbL.", "oss_attributions": "Attributions Open Source", "other_attributions": "Des attributions supplémentaires peuvent être trouvées dans le fichier README.", - "source_code": "Code source" + "source_code": "Code source", + "generic_attributions": "Connectez-vous à AdventureLog pour afficher les attributions pour les intégrations et services activés." }, "adventures": { "activities": { @@ -267,7 +268,8 @@ "sun_times": "Temps du soleil", "sunrise": "Lever du soleil", "sunset": "Coucher de soleil", - "timed": "Chronométré" + "timed": "Chronométré", + "distance": "Distance" }, "home": { "desc_1": "Découvrez, planifiez et explorez en toute simplicité", diff --git a/frontend/src/locales/it.json b/frontend/src/locales/it.json index 5a17f6b..2970f1c 100644 --- a/frontend/src/locales/it.json +++ b/frontend/src/locales/it.json @@ -8,7 +8,8 @@ "nominatim_2": "I loro dati sono concessi in licenza con la licenza ODbL.", "oss_attributions": "Attribuzioni Open Source", "other_attributions": "Ulteriori attribuzioni possono essere trovate nel file README.", - "source_code": "Codice sorgente" + "source_code": "Codice sorgente", + "generic_attributions": "Accedi a AdventureLog per visualizzare le attribuzioni per integrazioni e servizi abilitati." }, "adventures": { "activities": { @@ -267,7 +268,8 @@ "sun_times": "Sun Times", "sunrise": "Alba", "sunset": "Tramonto", - "timed": "A tempo" + "timed": "A tempo", + "distance": "Distanza" }, "home": { "desc_1": "Scopri, pianifica ed esplora con facilità", diff --git a/frontend/src/locales/ko.json b/frontend/src/locales/ko.json index 88d92ef..54a4d22 100644 --- a/frontend/src/locales/ko.json +++ b/frontend/src/locales/ko.json @@ -8,7 +8,8 @@ "nominatim_2": "데이터는 ODbL 라이선스가 적용됩니다.", "oss_attributions": "오픈 소스 속성", "other_attributions": "추가 속성은 README 파일에서 찾을 수 있습니다.", - "source_code": "소스 코드" + "source_code": "소스 코드", + "generic_attributions": "Adventurelog에 로그인하여 활성화 된 통합 및 서비스에 대한 속성을보십시오." }, "adventures": { "actions": "행동", @@ -267,7 +268,8 @@ "sun_times": "태양 시간", "sunrise": "해돋이", "sunset": "일몰", - "timed": "시간이 정해졌습니다" + "timed": "시간이 정해졌습니다", + "distance": "거리" }, "auth": { "both_passwords_required": "두 암호 모두 필요합니다", diff --git a/frontend/src/locales/nl.json b/frontend/src/locales/nl.json index 934cfcf..7dbdb40 100644 --- a/frontend/src/locales/nl.json +++ b/frontend/src/locales/nl.json @@ -8,7 +8,8 @@ "nominatim_2": "Hun gegevens zijn in licentie gegeven onder de ODbL-licentie.", "oss_attributions": "Open source gebruik", "other_attributions": "Aanvullende vermeldingen zijn te vinden in het README-bestand.", - "source_code": "Broncode" + "source_code": "Broncode", + "generic_attributions": "Log in op AdventUrelog om attributies te bekijken voor ingeschakelde integraties en services." }, "adventures": { "activities": { @@ -267,7 +268,8 @@ "sun_times": "Zonnetijden", "sunrise": "Zonsopgang", "sunset": "Zonsondergang", - "timed": "Getimed" + "timed": "Getimed", + "distance": "Afstand" }, "home": { "desc_1": "Ontdek, plan en verken met gemak", diff --git a/frontend/src/locales/no.json b/frontend/src/locales/no.json index 936c530..04d9171 100644 --- a/frontend/src/locales/no.json +++ b/frontend/src/locales/no.json @@ -42,7 +42,8 @@ "nominatim_1": "Stedsøk og geokoding leveres av", "nominatim_2": "Deres data er lisensiert under ODbL-lisensen.", "other_attributions": "Ytterligere attribusjoner finnes i README-filen.", - "close": "Lukk" + "close": "Lukk", + "generic_attributions": "Logg inn på Adventurelog for å se attribusjoner for aktiverte integrasjoner og tjenester." }, "home": { "hero_1": "Oppdag verdens mest spennende eventyr", @@ -315,7 +316,8 @@ "sun_times": "Soltider", "sunrise": "Soloppgang", "sunset": "Solnedgang", - "timed": "Tidsbestemt" + "timed": "Tidsbestemt", + "distance": "Avstand" }, "worldtravel": { "country_list": "Liste over land", diff --git a/frontend/src/locales/pl.json b/frontend/src/locales/pl.json index 0e488ef..fb5b73a 100644 --- a/frontend/src/locales/pl.json +++ b/frontend/src/locales/pl.json @@ -42,7 +42,8 @@ "nominatim_1": "Wyszukiwanie lokalizacji i geokodowanie zapewnia", "nominatim_2": "Ich dane są licencjonowane na licencji ODbL.", "other_attributions": "Dodatkowe atrybucje można znaleźć w pliku README.", - "close": "Zamknij" + "close": "Zamknij", + "generic_attributions": "Zaloguj się do Adventurelog, aby wyświetlić atrybucje dla włączonych integracji i usług." }, "home": { "hero_1": "Odkryj najbardziej ekscytujące podróże na świecie", @@ -315,7 +316,8 @@ "sun_times": "Czasy słońca", "sunrise": "Wschód słońca", "sunset": "Zachód słońca", - "timed": "Czas" + "timed": "Czas", + "distance": "Dystans" }, "worldtravel": { "country_list": "Lista krajów", diff --git a/frontend/src/locales/sv.json b/frontend/src/locales/sv.json index e659f0c..83956ce 100644 --- a/frontend/src/locales/sv.json +++ b/frontend/src/locales/sv.json @@ -8,7 +8,8 @@ "nominatim_2": "Deras data är licensierad under ODbL-licensen.", "oss_attributions": "Tillskrivningar med öppen källkod", "other_attributions": "Ytterligare attributioner finns i README-filen.", - "source_code": "Källkod" + "source_code": "Källkod", + "generic_attributions": "Logga in på AdventureLog för att visa attribut för aktiverade integrationer och tjänster." }, "adventures": { "activities": { @@ -267,7 +268,8 @@ "sun_times": "Soltider", "sunrise": "Soluppgång", "sunset": "Solnedgång", - "timed": "Tidsinställd" + "timed": "Tidsinställd", + "distance": "Avstånd" }, "home": { "desc_1": "Upptäck, planera och utforska med lätthet", diff --git a/frontend/src/locales/zh.json b/frontend/src/locales/zh.json index 229f931..0351dcf 100644 --- a/frontend/src/locales/zh.json +++ b/frontend/src/locales/zh.json @@ -42,7 +42,8 @@ "oss_attributions": "开源声明", "other_attributions": "其他声明可以在 README 文件中找到。", "source_code": "源代码", - "close": "关闭" + "close": "关闭", + "generic_attributions": "登录到AdventureLog以查看启用集成和服务的归因。" }, "home": { "desc_1": "轻松发现、规划和探索", @@ -315,7 +316,8 @@ "sun_times": "阳光时代", "sunrise": "日出", "sunset": "日落", - "timed": "时间" + "timed": "时间", + "distance": "距离" }, "auth": { "forgot_password": "忘记密码?",