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

View File

@ -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 (

View File

@ -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):