get spaces

This commit is contained in:
mi1468 2025-05-27 14:48:29 +03:30
parent e630622529
commit ef3e03f22c

View File

@ -1163,6 +1163,15 @@ def addSpace(request):
data = request.data.copy() data = request.data.copy()
data['userId'] = request.user.id # Automatically assign the authenticated user data['userId'] = request.user.id # Automatically assign the authenticated user
# Retrieve the AssetBundleRoom instance from the provided ID
try:
asset_bundle_room = AssetBundleRoom.objects.get(id=data['assetBundleRoomId'])
except AssetBundleRoom.DoesNotExist:
return Response({"detail": "AssetBundleRoom not found."}, status=status.HTTP_404_NOT_FOUND)
# Assign the AssetBundleRoom instance to the data
data['assetBundleRoomId'] = asset_bundle_room
# Pass the request object to the serializer context # Pass the request object to the serializer context
serializer = SpaceSerializer(data=data) serializer = SpaceSerializer(data=data)
@ -1179,8 +1188,3 @@ def addSpace(request):
else: else:
# If validation fails, return the errors # If validation fails, return the errors
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)