1
0
Fork 0
mirror of https://github.com/seanmorley15/AdventureLog.git synced 2025-07-24 07:19:36 +02:00

collection update

This commit is contained in:
Sean Morley 2024-07-16 09:26:45 -04:00
parent e679eada06
commit 9e78a1bc4f
4 changed files with 29 additions and 9 deletions

View file

@ -80,6 +80,18 @@ class AdventureViewSet(viewsets.ModelViewSet):
serializer = self.get_serializer(adventure)
return Response(serializer.data)
def perform_create(self, serializer):
adventure = serializer.save(user_id=self.request.user)
if adventure.collection:
adventure.is_public = adventure.collection.is_public
adventure.save()
def perform_update(self, serializer):
adventure = serializer.save()
if adventure.collection:
adventure.is_public = adventure.collection.is_public
adventure.save()
def perform_create(self, serializer):
serializer.save(user_id=self.request.user)