diff --git a/backend/server/adventures/views.py b/backend/server/adventures/views.py
index e658623..e981fcc 100644
--- a/backend/server/adventures/views.py
+++ b/backend/server/adventures/views.py
@@ -175,6 +175,10 @@ class CollectionViewSet(viewsets.ModelViewSet):
permission_classes = [IsOwnerOrReadOnly, IsPublicReadOnly]
pagination_class = StandardResultsSetPagination
+ def get_queryset(self):
+ print(self.request.user.id)
+ return Collection.objects.filter(user_id=self.request.user.id)
+
def apply_sorting(self, queryset):
order_by = self.request.query_params.get('order_by', 'name')
order_direction = self.request.query_params.get('order_direction', 'asc')
@@ -255,9 +259,19 @@ class CollectionViewSet(viewsets.ModelViewSet):
return Response(serializer.data)
def get_queryset(self):
- collections = Collection.objects.filter(
- Q(is_public=True) | Q(user_id=self.request.user.id)
- ).prefetch_related(
+
+ adventures = None
+
+ if self.action == 'retrieve':
+ # For individual collection retrieval, include public collections
+ adventures = Collection.objects.filter(
+ Q(is_public=True) | Q(user_id=self.request.user.id)
+ )
+ else:
+ # For other actions, only include user's own collections
+ adventures = Collection.objects.filter(user_id=self.request.user.id)
+
+ adventures = adventures.prefetch_related(
Prefetch('adventure_set', queryset=Adventure.objects.filter(
Q(is_public=True) | Q(user_id=self.request.user.id)
))
@@ -266,7 +280,7 @@ class CollectionViewSet(viewsets.ModelViewSet):
Q(is_public=True) | Q(user_id=self.request.user.id)
))
)
- return self.apply_sorting(collections)
+ return self.apply_sorting(adventures)
def perform_create(self, serializer):
serializer.save(user_id=self.request.user)
diff --git a/frontend/src/routes/map/+page.svelte b/frontend/src/routes/map/+page.svelte
index ee9d760..4cdfd64 100644
--- a/frontend/src/routes/map/+page.svelte
+++ b/frontend/src/routes/map/+page.svelte
@@ -19,7 +19,6 @@
let showVisited = true;
let showPlanned = true;
- let showCollectionAdventures = false;
$: {
if (!showVisited) {
@@ -34,12 +33,6 @@
const plannedMarkers = data.props.markers.filter((marker) => marker.type === 'planned');
markers = [...markers, ...plannedMarkers];
}
- if (!showCollectionAdventures) {
- markers = markers.filter((marker) => marker.collection === null);
- } else {
- const collectionMarkers = data.props.markers.filter((marker) => marker.collection !== null);
- markers = [...markers, ...collectionMarkers];
- }
}
let newMarker = [];
@@ -124,14 +117,6 @@
Planned
-
{#if newMarker.length > 0}