From eb85e04a099edbcd9c511c0de1b5db4c370ffa11 Mon Sep 17 00:00:00 2001 From: pablohashescobar Date: Tue, 13 Dec 2022 23:36:30 +0530 Subject: [PATCH] fix: segregate my issues with workspace --- apiserver/plane/api/urls.py | 6 ++++++ apiserver/plane/api/views/__init__.py | 3 ++- apiserver/plane/api/views/issue.py | 15 +++++++++++++++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/apiserver/plane/api/urls.py b/apiserver/plane/api/urls.py index 6aa0d5aea..68ce32bd0 100644 --- a/apiserver/plane/api/urls.py +++ b/apiserver/plane/api/urls.py @@ -55,6 +55,7 @@ from plane.api.views import ( BulkDeleteIssuesEndpoint, BulkAssignIssuesToCycleEndpoint, ProjectUserViewsEndpoint, + UserWorkSpaceIssues, ) from plane.api.views.project import AddTeamToProjectEndpoint @@ -495,6 +496,11 @@ urlpatterns = [ "workspaces//projects//bulk-delete-issues/", BulkDeleteIssuesEndpoint.as_view(), ), + path( + "workspaces//me/issues/", + UserWorkSpaceIssues.as_view(), + name="workspace-issues", + ), ## End Issues ## Issue Activity path( diff --git a/apiserver/plane/api/views/__init__.py b/apiserver/plane/api/views/__init__.py index f4112178a..a6bb70af0 100644 --- a/apiserver/plane/api/views/__init__.py +++ b/apiserver/plane/api/views/__init__.py @@ -9,7 +9,7 @@ from .project import ( ProjectIdentifierEndpoint, AddMemberToProjectEndpoint, ProjectJoinEndpoint, - ProjectUserViewsEndpoint, + ProjectUserViewsEndpoint, ) from .people import ( PeopleEndpoint, @@ -48,6 +48,7 @@ from .issue import ( IssuePropertyViewSet, LabelViewSet, BulkDeleteIssuesEndpoint, + UserWorkSpaceIssues, ) from .auth_extended import ( diff --git a/apiserver/plane/api/views/issue.py b/apiserver/plane/api/views/issue.py index e5465b15f..530685a0f 100644 --- a/apiserver/plane/api/views/issue.py +++ b/apiserver/plane/api/views/issue.py @@ -173,6 +173,21 @@ class UserIssuesEndpoint(BaseAPIView): status=status.HTTP_500_INTERNAL_SERVER_ERROR, ) +class UserWorkSpaceIssues(BaseAPIView): + def get(self, request, slug): + try: + print(request.user) + issues = Issue.objects.filter( + assignees__in=[request.user], workspace__slug=slug + ) + serializer = IssueSerializer(issues, many=True) + return Response(serializer.data, status=status.HTTP_200_OK) + except Exception as e: + capture_exception(e) + return Response( + {"error": "Something went wrong please try again later"}, + status=status.HTTP_500_INTERNAL_SERVER_ERROR, + ) class WorkSpaceIssuesEndpoint(BaseAPIView):