From be86a7d38eac5035c7642b32c1d414174112cbdd Mon Sep 17 00:00:00 2001 From: Nikhil <118773738+pablohashescobar@users.noreply.github.com> Date: Fri, 11 Aug 2023 12:46:29 +0530 Subject: [PATCH] feat: project member role (#1828) --- apiserver/plane/api/serializers/project.py | 1 + apiserver/plane/api/views/project.py | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/apiserver/plane/api/serializers/project.py b/apiserver/plane/api/serializers/project.py index 643518daa..9e30976ec 100644 --- a/apiserver/plane/api/serializers/project.py +++ b/apiserver/plane/api/serializers/project.py @@ -94,6 +94,7 @@ class ProjectDetailSerializer(BaseSerializer): total_modules = serializers.IntegerField(read_only=True) is_member = serializers.BooleanField(read_only=True) sort_order = serializers.FloatField(read_only=True) + member_role = serializers.IntegerField(read_only=True) class Meta: model = Project diff --git a/apiserver/plane/api/views/project.py b/apiserver/plane/api/views/project.py index 5911011b5..7387accd6 100644 --- a/apiserver/plane/api/views/project.py +++ b/apiserver/plane/api/views/project.py @@ -110,6 +110,12 @@ class ProjectViewSet(BaseViewSet): .annotate(count=Func(F("id"), function="Count")) .values("count") ) + .annotate( + member_role=ProjectMember.objects.filter( + project_id=OuterRef("pk"), + member_id=self.request.user.id, + ).values("role") + ) .distinct() )