mirror of
https://github.com/seanmorley15/AdventureLog.git
synced 2025-07-19 12:59:36 +02:00
commit
31aefff74e
4 changed files with 30 additions and 19 deletions
|
@ -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)
|
||||
|
|
|
@ -8,6 +8,9 @@ services:
|
|||
- PUBLIC_SERVER_URL=http://server:8000
|
||||
- ORIGIN=http://localhost:8080
|
||||
- BODY_SIZE_LIMIT=Infinity
|
||||
# Analytics can be configured here using Umami (https://umami.is)
|
||||
- ENABLE_ANALYTICS=false
|
||||
#- UNAMI_KEY=''
|
||||
ports:
|
||||
- "8080:3000"
|
||||
depends_on:
|
||||
|
|
|
@ -3,8 +3,17 @@
|
|||
import Toast from '$lib/components/Toast.svelte';
|
||||
import 'tailwindcss/tailwind.css';
|
||||
export let data;
|
||||
|
||||
const enableAnalytics = process.env['ENABLE_ANALYTICS'] || 'false';
|
||||
const unamiKey = process.env['UNAMI_KEY'] || '';
|
||||
</script>
|
||||
|
||||
<svelte:head>
|
||||
{#if enableAnalytics === 'true' && unamiKey}
|
||||
<script defer src="https://cloud.umami.is/script.js" data-website-id={unamiKey}></script>
|
||||
{/if}
|
||||
</svelte:head>
|
||||
|
||||
<Navbar {data} />
|
||||
<Toast />
|
||||
|
||||
|
|
|
@ -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 @@
|
|||
<span class="label-text">Planned</span>
|
||||
<input type="checkbox" bind:checked={showPlanned} class="checkbox checkbox-primary" />
|
||||
</label>
|
||||
<label class="label cursor-pointer">
|
||||
<span class="label-text">Collection Adventures</span>
|
||||
<input
|
||||
type="checkbox"
|
||||
bind:checked={showCollectionAdventures}
|
||||
class="checkbox checkbox-primary"
|
||||
/>
|
||||
</label>
|
||||
|
||||
{#if newMarker.length > 0}
|
||||
<button type="button" class="btn btn-primary mb-2" on:click={() => (createModalOpen = true)}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue