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:
Nikhil 2023-08-01 14:15:40 +05:30 committed by GitHub
parent 7a6e742362
commit 6e7fa1a39c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 5 deletions

View File

@ -176,7 +176,7 @@ class ProjectViewSet(BaseViewSet):
serializer.save()
# 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
)
@ -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(
[serializer.errors[error][0] for error in serializer.errors],
serializer.errors,
status=status.HTTP_400_BAD_REQUEST,
)
except IntegrityError as e:
@ -265,7 +267,7 @@ class ProjectViewSet(BaseViewSet):
status=status.HTTP_410_GONE,
)
except Exception as e:
capture_exception(e)
pr(e)
return Response(
{"error": "Something went wrong please try again later"},
status=status.HTTP_400_BAD_REQUEST,

View File

@ -161,7 +161,7 @@ class ProjectMember(ProjectBaseModel):
def save(self, *args, **kwargs):
if self._state.adding:
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"]
# Project ordering