From 2bacbedeb7a697ce28d6db25a3e0ed971490c88a Mon Sep 17 00:00:00 2001 From: pablohashescobar Date: Fri, 16 Dec 2022 21:30:04 +0530 Subject: [PATCH 1/2] feat: create a dedicated endpoint to view logged in users project attributes --- apiserver/plane/api/urls.py | 7 +++++++ apiserver/plane/api/views/__init__.py | 1 + apiserver/plane/api/views/project.py | 24 ++++++++++++++++++++++++ 3 files changed, 32 insertions(+) diff --git a/apiserver/plane/api/urls.py b/apiserver/plane/api/urls.py index ef53b4519..2b1dabbf2 100644 --- a/apiserver/plane/api/urls.py +++ b/apiserver/plane/api/urls.py @@ -58,6 +58,7 @@ from plane.api.views import ( ModuleIssueViewSet, UserLastProjectWithWorkspaceEndpoint, UserWorkSpaceIssues, + ProjectMemberUserEndpoint, ) from plane.api.views.project import AddTeamToProjectEndpoint @@ -320,6 +321,12 @@ urlpatterns = [ ProjectUserViewsEndpoint.as_view(), name="project-view", ), + path( + "workspaces//projects//project-member/me/", + ProjectMemberUserEndpoint.as_view(), + name="project-view", + ), + # End Projects # States path( "workspaces//projects//states/", diff --git a/apiserver/plane/api/views/__init__.py b/apiserver/plane/api/views/__init__.py index b55342f87..5706b1994 100644 --- a/apiserver/plane/api/views/__init__.py +++ b/apiserver/plane/api/views/__init__.py @@ -10,6 +10,7 @@ from .project import ( AddMemberToProjectEndpoint, ProjectJoinEndpoint, ProjectUserViewsEndpoint, + ProjectMemberUserEndpoint, ) from .people import ( PeopleEndpoint, diff --git a/apiserver/plane/api/views/project.py b/apiserver/plane/api/views/project.py index dafc62743..3a18ef85d 100644 --- a/apiserver/plane/api/views/project.py +++ b/apiserver/plane/api/views/project.py @@ -625,3 +625,27 @@ class ProjectUserViewsEndpoint(BaseAPIView): {"error": "Something went wrong please try again later"}, status=status.HTTP_500_INTERNAL_SERVER_ERROR, ) + + +class ProjectMemberUserEndpoint(BaseAPIView): + def get(self, request, slug, project_id): + try: + + project_member = ProjectMember.objects.get( + project=project_id, workpsace__slug=slug, member=request.user + ) + serializer = ProjectMemberSerializer(project_member) + + return Response(serializer.data, status=status.HTTP_200_OK) + + except ProjectMember.DoesNotExist: + return Response( + {"error": "User not a member of the project"}, + status=status.HTTP_404_NOT_FOUND, + ) + except Exception as e: + capture_exception(e) + return Response( + {"error": "Something went wrong please try again later"}, + status=status.HTTP_500_INTERNAL_SERVER_ERROR, + ) From 8aecc143c7f2626d60769b3707d1047076fe2972 Mon Sep 17 00:00:00 2001 From: pablohashescobar Date: Fri, 16 Dec 2022 21:33:34 +0530 Subject: [PATCH 2/2] feat: update url --- apiserver/plane/api/urls.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apiserver/plane/api/urls.py b/apiserver/plane/api/urls.py index 2b1dabbf2..d4a9faa6f 100644 --- a/apiserver/plane/api/urls.py +++ b/apiserver/plane/api/urls.py @@ -322,7 +322,7 @@ urlpatterns = [ name="project-view", ), path( - "workspaces//projects//project-member/me/", + "workspaces//projects//project-members/me/", ProjectMemberUserEndpoint.as_view(), name="project-view", ),