From 0866dc34940963afd0b0f941443e302e1e3bb18f Mon Sep 17 00:00:00 2001 From: pablohashescobar Date: Tue, 1 Aug 2023 21:42:48 +0530 Subject: [PATCH 1/2] fix: project invite --- apiserver/plane/api/views/project.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apiserver/plane/api/views/project.py b/apiserver/plane/api/views/project.py index 0589f4a61..d35f44ded 100644 --- a/apiserver/plane/api/views/project.py +++ b/apiserver/plane/api/views/project.py @@ -603,7 +603,7 @@ class AddMemberToProjectEndpoint(BaseAPIView): bulk_project_members = [] project_members = ProjectMember.objects.filter( - workspace=self.workspace, member_id__in=[member.get("member_id") for member in members] + workspace__slug=slug, member_id__in=[member.get("member_id") for member in members] ).values("member_id").annotate(sort_order_min=Min("sort_order")) for member in members: From f41086fd2671501df6371316f64352c8386831d3 Mon Sep 17 00:00:00 2001 From: pablohashescobar Date: Tue, 1 Aug 2023 22:00:56 +0530 Subject: [PATCH 2/2] fix: typeerror --- apiserver/plane/api/views/project.py | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/apiserver/plane/api/views/project.py b/apiserver/plane/api/views/project.py index d35f44ded..31741f10c 100644 --- a/apiserver/plane/api/views/project.py +++ b/apiserver/plane/api/views/project.py @@ -123,7 +123,7 @@ class ProjectViewSet(BaseViewSet): sort_order_query = ProjectMember.objects.filter( member=request.user, project_id=OuterRef("pk"), - workspace__slug=self.kwargs.get("slug"), + workspace__slug=self.kwargs.get("slug"), ).values("sort_order") projects = ( self.get_queryset() @@ -602,19 +602,29 @@ class AddMemberToProjectEndpoint(BaseAPIView): ) bulk_project_members = [] - project_members = ProjectMember.objects.filter( - workspace__slug=slug, member_id__in=[member.get("member_id") for member in members] - ).values("member_id").annotate(sort_order_min=Min("sort_order")) + project_members = ( + ProjectMember.objects.filter( + workspace__slug=slug, + member_id__in=[member.get("member_id") for member in members], + ) + .values("member_id", "sort_order") + .order_by("sort_order") + ) for member in members: - sort_order = [project_member.get("sort_order") for project_member in project_members] + sort_order = [ + project_member.get("sort_order") + for project_member in project_members + if str(project_member.get("member_id")) + == str(member.get("member_id")) + ] bulk_project_members.append( ProjectMember( member_id=member.get("member_id"), role=member.get("role", 10), project_id=project_id, workspace_id=project.workspace_id, - sort_order=sort_order[0] - 10000 if len(sort_order) else 65535 + sort_order=sort_order[0] - 10000 if len(sort_order) else 65535, ) )