Skip to content

Commit

Permalink
Merge pull request #172 from seanmorley15/development
Browse files Browse the repository at this point in the history
fix serializer issues for world travel
  • Loading branch information
seanmorley15 authored Aug 6, 2024
2 parents 290505d + 493c250 commit 1efa19b
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions backend/server/worldtravel/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,19 @@ class VisitedRegionViewSet(viewsets.ModelViewSet):

def get_queryset(self):
return VisitedRegion.objects.filter(user_id=self.request.user.id)

def perform_create(self, serializer):
serializer.save(user_id=self.request.user)

def create(self, request, *args, **kwargs):
# Set the user_id to the request user's ID
request.data['user_id'] = request.user.id
request.data['user_id'] = request.user
serializer = self.get_serializer(data=request.data)
serializer.is_valid(raise_exception=True)
self.perform_create(serializer)
headers = self.get_success_headers(serializer.data)
return Response(serializer.data, status=status.HTTP_201_CREATED, headers=headers)


class GeoJSONView(viewsets.ViewSet):
"""
Combine all GeoJSON data from .json files in static/data into a single GeoJSON object.
Expand Down

0 comments on commit 1efa19b

Please sign in to comment.