diff --git a/backend/server/adventures/views.py b/backend/server/adventures/views.py index 03b5303..2380036 100644 --- a/backend/server/adventures/views.py +++ b/backend/server/adventures/views.py @@ -109,15 +109,18 @@ class AdventureViewSet(viewsets.ModelViewSet): # Handle case where types is all if 'all' in types: - types = [t[0] for t in ADVENTURE_TYPES] - valid_types = [t[0] for t in ADVENTURE_TYPES] - types = [t for t in types if t in valid_types] + types = Category.objects.filter(user_id=request.user).values_list('name', flat=True) + + else: + for type in types: + if not Category.objects.filter(user_id=request.user, name=type).exists(): + return Response({"error": f"Category {type} does not exist"}, status=400) if not types: return Response({"error": "No valid types provided"}, status=400) queryset = Adventure.objects.filter( - type__in=types, + category__in=Category.objects.filter(name__in=types, user_id=request.user), user_id=request.user.id ) diff --git a/frontend/src/lib/components/AdventureCard.svelte b/frontend/src/lib/components/AdventureCard.svelte index 25714d1..519d976 100644 --- a/frontend/src/lib/components/AdventureCard.svelte +++ b/frontend/src/lib/components/AdventureCard.svelte @@ -129,7 +129,9 @@
-
{$t(`adventures.activities.${adventure.type}`)}
+
+ {`${adventure.category.display_name} ${adventure.category.icon}`} +
{adventure.is_visited ? $t('adventures.visited') : $t('adventures.planned')}
diff --git a/frontend/src/lib/components/RegionCard.svelte b/frontend/src/lib/components/RegionCard.svelte index cdfa041..c9754f0 100644 --- a/frontend/src/lib/components/RegionCard.svelte +++ b/frontend/src/lib/components/RegionCard.svelte @@ -28,7 +28,10 @@ let newVisit: VisitedRegion = { id: visit_id, region: region_id, - user_id: user_id + user_id: user_id, + longitude: 0, + latitude: 0, + name: '' }; addToast('success', `Visit to ${region.name} marked`); dispatch('visit', newVisit); diff --git a/frontend/src/lib/types.ts b/frontend/src/lib/types.ts index 758f7c9..81a20c3 100644 --- a/frontend/src/lib/types.ts +++ b/frontend/src/lib/types.ts @@ -38,6 +38,13 @@ export type Adventure = { created_at?: string | null; updated_at?: string | null; is_visited?: boolean; + category: { + id: string; + name: string; + display_name: string; + icon: string; + user_id: number; + }; }; export type Country = {