diff --git a/apiserver/plane/api/views/project.py b/apiserver/plane/api/views/project.py index 6f15069ed..6adee0016 100644 --- a/apiserver/plane/api/views/project.py +++ b/apiserver/plane/api/views/project.py @@ -122,7 +122,9 @@ class ProjectViewSet(BaseViewSet): ) ) .annotate( - total_members=ProjectMember.objects.filter(project_id=OuterRef("id")) + total_members=ProjectMember.objects.filter( + project_id=OuterRef("id"), member__is_bot=False + ) .order_by() .annotate(count=Func(F("id"), function="Count")) .values("count") @@ -393,7 +395,9 @@ class InviteProjectEndpoint(BaseAPIView): validate_email(email) # Check if user is already a member of workspace if ProjectMember.objects.filter( - project_id=project_id, member__email=email + project_id=project_id, + member__email=email, + member__is_bot=False, ).exists(): return Response( {"error": "User is already member of workspace"}, @@ -1097,7 +1101,9 @@ class ProjectMemberEndpoint(BaseAPIView): def get(self, request, slug, project_id): try: project_members = ProjectMember.objects.filter( - project_id=project_id, workspace__slug=slug + project_id=project_id, + workspace__slug=slug, + member__is_bot=False, ).select_related("project", "member") serializer = ProjectMemberSerializer(project_members, many=True) return Response(serializer.data, status=status.HTTP_200_OK) diff --git a/apiserver/plane/api/views/workspace.py b/apiserver/plane/api/views/workspace.py index 3957bcae0..eca18163a 100644 --- a/apiserver/plane/api/views/workspace.py +++ b/apiserver/plane/api/views/workspace.py @@ -47,7 +47,7 @@ from plane.api.serializers import ( WorkspaceThemeSerializer, IssueActivitySerializer, IssueLiteSerializer, - WorkspaceMemberAdminSerializer + WorkspaceMemberAdminSerializer, ) from plane.api.views.base import BaseAPIView from . import BaseViewSet @@ -107,7 +107,9 @@ class WorkSpaceViewSet(BaseViewSet): def get_queryset(self): member_count = ( - WorkspaceMember.objects.filter(workspace=OuterRef("id")) + WorkspaceMember.objects.filter( + workspace=OuterRef("id"), member__is_bot=False + ) .order_by() .annotate(count=Func(F("id"), function="Count")) .values("count") @@ -192,7 +194,9 @@ class UserWorkSpacesEndpoint(BaseAPIView): def get(self, request): try: member_count = ( - WorkspaceMember.objects.filter(workspace=OuterRef("id")) + WorkspaceMember.objects.filter( + workspace=OuterRef("id"), member__is_bot=False + ) .order_by() .annotate(count=Func(F("id"), function="Count")) .values("count") @@ -625,7 +629,9 @@ class WorkSpaceMemberViewSet(BaseViewSet): if ( workspace_member.role == 20 and WorkspaceMember.objects.filter( - workspace__slug=slug, role=20 + workspace__slug=slug, + role=20, + member__is_bot=False, ).count() == 1 ): @@ -1455,7 +1461,8 @@ class WorkspaceMembersEndpoint(BaseAPIView): def get(self, request, slug): try: workspace_members = WorkspaceMember.objects.filter( - workspace__slug=slug + workspace__slug=slug, + member__is_bot=False, ).select_related("workspace", "member") serialzier = WorkSpaceMemberSerializer(workspace_members, many=True) return Response(serialzier.data, status=status.HTTP_200_OK)