forked from github/plane
fix: file asset uploads in workspace (#1234)
This commit is contained in:
parent
c05eb9e240
commit
382a1343ea
@ -6,7 +6,7 @@ from sentry_sdk import capture_exception
|
|||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
# Module imports
|
# Module imports
|
||||||
from .base import BaseAPIView
|
from .base import BaseAPIView
|
||||||
from plane.db.models import FileAsset
|
from plane.db.models import FileAsset, Workspace
|
||||||
from plane.api.serializers import FileAssetSerializer
|
from plane.api.serializers import FileAssetSerializer
|
||||||
|
|
||||||
|
|
||||||
@ -27,15 +27,13 @@ class FileAssetEndpoint(BaseAPIView):
|
|||||||
try:
|
try:
|
||||||
serializer = FileAssetSerializer(data=request.data)
|
serializer = FileAssetSerializer(data=request.data)
|
||||||
if serializer.is_valid():
|
if serializer.is_valid():
|
||||||
if request.user.last_workspace_id is None:
|
# Get the workspace
|
||||||
return Response(
|
workspace = Workspace.objects.get(slug=slug)
|
||||||
{"error": "Workspace id is required"},
|
serializer.save(workspace_id=workspace.id)
|
||||||
status=status.HTTP_400_BAD_REQUEST,
|
|
||||||
)
|
|
||||||
|
|
||||||
serializer.save(workspace_id=request.user.last_workspace_id)
|
|
||||||
return Response(serializer.data, status=status.HTTP_201_CREATED)
|
return Response(serializer.data, status=status.HTTP_201_CREATED)
|
||||||
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
|
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
|
||||||
|
except Workspace.DoesNotExist:
|
||||||
|
return Response({"error": "Workspace does not exist"}, status=status.HTTP_400_BAD_REQUEST)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
capture_exception(e)
|
capture_exception(e)
|
||||||
return Response(
|
return Response(
|
||||||
|
Loading…
Reference in New Issue
Block a user