mirror of
https://github.com/makeplane/plane
synced 2024-06-14 14:31:34 +00:00
chore: project create to return sort order (#1738)
* chore: project create retun sort order * chore: project create return sort order
This commit is contained in:
parent
7a6e742362
commit
6e7fa1a39c
@ -176,7 +176,7 @@ class ProjectViewSet(BaseViewSet):
|
|||||||
serializer.save()
|
serializer.save()
|
||||||
|
|
||||||
# Add the user as Administrator to the project
|
# Add the user as Administrator to the project
|
||||||
ProjectMember.objects.create(
|
project_member = ProjectMember.objects.create(
|
||||||
project_id=serializer.data["id"], member=request.user, role=20
|
project_id=serializer.data["id"], member=request.user, role=20
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -238,9 +238,11 @@ class ProjectViewSet(BaseViewSet):
|
|||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
return Response(serializer.data, status=status.HTTP_201_CREATED)
|
data = serializer.data
|
||||||
|
data["sort_order"] = project_member.sort_order
|
||||||
|
return Response(data, status=status.HTTP_201_CREATED)
|
||||||
return Response(
|
return Response(
|
||||||
[serializer.errors[error][0] for error in serializer.errors],
|
serializer.errors,
|
||||||
status=status.HTTP_400_BAD_REQUEST,
|
status=status.HTTP_400_BAD_REQUEST,
|
||||||
)
|
)
|
||||||
except IntegrityError as e:
|
except IntegrityError as e:
|
||||||
@ -265,7 +267,7 @@ class ProjectViewSet(BaseViewSet):
|
|||||||
status=status.HTTP_410_GONE,
|
status=status.HTTP_410_GONE,
|
||||||
)
|
)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
capture_exception(e)
|
pr(e)
|
||||||
return Response(
|
return Response(
|
||||||
{"error": "Something went wrong please try again later"},
|
{"error": "Something went wrong please try again later"},
|
||||||
status=status.HTTP_400_BAD_REQUEST,
|
status=status.HTTP_400_BAD_REQUEST,
|
||||||
|
@ -161,7 +161,7 @@ class ProjectMember(ProjectBaseModel):
|
|||||||
def save(self, *args, **kwargs):
|
def save(self, *args, **kwargs):
|
||||||
if self._state.adding:
|
if self._state.adding:
|
||||||
smallest_sort_order = ProjectMember.objects.filter(
|
smallest_sort_order = ProjectMember.objects.filter(
|
||||||
workspace=self.workspace, member=self.member
|
workspace_id=self.project.workspace_id, member=self.member
|
||||||
).aggregate(smallest=models.Min("sort_order"))["smallest"]
|
).aggregate(smallest=models.Min("sort_order"))["smallest"]
|
||||||
|
|
||||||
# Project ordering
|
# Project ordering
|
||||||
|
Loading…
Reference in New Issue
Block a user