mirror of
https://github.com/seanmorley15/AdventureLog.git
synced 2025-07-22 06:19:38 +02:00
Fix multiple adventures when shared with multiple users!
This commit is contained in:
parent
c1664e82bf
commit
7e110d8670
1 changed files with 3 additions and 3 deletions
|
@ -75,19 +75,19 @@ class AdventureViewSet(viewsets.ModelViewSet):
|
|||
# if the user is not authenticated return only public adventures for retrieve action
|
||||
if not self.request.user.is_authenticated:
|
||||
if self.action == 'retrieve':
|
||||
return Adventure.objects.filter(is_public=True).distinct()
|
||||
return Adventure.objects.filter(is_public=True).distinct().order_by('-updated_at')
|
||||
return Adventure.objects.none()
|
||||
|
||||
if self.action == 'retrieve':
|
||||
# For individual adventure retrieval, include public adventures
|
||||
return Adventure.objects.filter(
|
||||
Q(is_public=True) | Q(user_id=self.request.user.id) | Q(collection__shared_with=self.request.user)
|
||||
).distinct()
|
||||
).distinct().order_by('-updated_at')
|
||||
else:
|
||||
# For other actions, include user's own adventures and shared adventures
|
||||
return Adventure.objects.filter(
|
||||
Q(user_id=self.request.user.id) | Q(collection__shared_with=self.request.user)
|
||||
).distinct()
|
||||
).distinct().order_by('-updated_at')
|
||||
|
||||
def retrieve(self, request, *args, **kwargs):
|
||||
queryset = self.get_queryset()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue