fix: segregate my issues with workspace

This commit is contained in:
pablohashescobar 2022-12-13 23:36:30 +05:30
parent d2932a44a6
commit eb85e04a09
3 changed files with 23 additions and 1 deletions

View File

@ -55,6 +55,7 @@ from plane.api.views import (
BulkDeleteIssuesEndpoint, BulkDeleteIssuesEndpoint,
BulkAssignIssuesToCycleEndpoint, BulkAssignIssuesToCycleEndpoint,
ProjectUserViewsEndpoint, ProjectUserViewsEndpoint,
UserWorkSpaceIssues,
) )
from plane.api.views.project import AddTeamToProjectEndpoint from plane.api.views.project import AddTeamToProjectEndpoint
@ -495,6 +496,11 @@ urlpatterns = [
"workspaces/<str:slug>/projects/<uuid:project_id>/bulk-delete-issues/", "workspaces/<str:slug>/projects/<uuid:project_id>/bulk-delete-issues/",
BulkDeleteIssuesEndpoint.as_view(), BulkDeleteIssuesEndpoint.as_view(),
), ),
path(
"workspaces/<str:slug>/me/issues/",
UserWorkSpaceIssues.as_view(),
name="workspace-issues",
),
## End Issues ## End Issues
## Issue Activity ## Issue Activity
path( path(

View File

@ -9,7 +9,7 @@ from .project import (
ProjectIdentifierEndpoint, ProjectIdentifierEndpoint,
AddMemberToProjectEndpoint, AddMemberToProjectEndpoint,
ProjectJoinEndpoint, ProjectJoinEndpoint,
ProjectUserViewsEndpoint, ProjectUserViewsEndpoint,
) )
from .people import ( from .people import (
PeopleEndpoint, PeopleEndpoint,
@ -48,6 +48,7 @@ from .issue import (
IssuePropertyViewSet, IssuePropertyViewSet,
LabelViewSet, LabelViewSet,
BulkDeleteIssuesEndpoint, BulkDeleteIssuesEndpoint,
UserWorkSpaceIssues,
) )
from .auth_extended import ( from .auth_extended import (

View File

@ -173,6 +173,21 @@ class UserIssuesEndpoint(BaseAPIView):
status=status.HTTP_500_INTERNAL_SERVER_ERROR, 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): class WorkSpaceIssuesEndpoint(BaseAPIView):