From 921763058064c257926b6486b58674ff013482f1 Mon Sep 17 00:00:00 2001 From: NarayanBavisetti Date: Tue, 21 Nov 2023 15:17:35 +0530 Subject: [PATCH] chore: bug fix --- apiserver/plane/api/serializers/issue.py | 3 ++- apiserver/plane/api/urls/issue.py | 2 +- apiserver/plane/api/urls/project.py | 2 +- apiserver/plane/api/views/issue.py | 2 +- apiserver/plane/api/views/project.py | 12 ++++++------ apiserver/plane/app/urls/project.py | 2 +- apiserver/plane/app/views/issue.py | 2 +- 7 files changed, 13 insertions(+), 12 deletions(-) diff --git a/apiserver/plane/api/serializers/issue.py b/apiserver/plane/api/serializers/issue.py index 8fcab0a38..9ac0d4a17 100644 --- a/apiserver/plane/api/serializers/issue.py +++ b/apiserver/plane/api/serializers/issue.py @@ -63,6 +63,7 @@ class IssueSerializer(BaseSerializer): print(data.get("assignees")) data["assignees"] = ProjectMember.objects.filter( project_id=self.context.get("project_id"), + is_active=True, member_id__in=data["assignees"], ).values_list("member_id", flat=True) @@ -88,7 +89,7 @@ class IssueSerializer(BaseSerializer): if ( data.get("parent") and not Issue.objects.filter( - workspce_id=self.context.get("workspace_id"), pk=data.get("parent") + workspace_id=self.context.get("workspace_id"), pk=data.get("parent") ).exists() ): raise serializers.ValidationError( diff --git a/apiserver/plane/api/urls/issue.py b/apiserver/plane/api/urls/issue.py index 910fda5e1..e6770579d 100644 --- a/apiserver/plane/api/urls/issue.py +++ b/apiserver/plane/api/urls/issue.py @@ -15,7 +15,7 @@ urlpatterns = [ name="issue", ), path( - "workspaces//projects//issues//", + "workspaces//projects//issues//", IssueAPIEndpoint.as_view(), name="issue", ), diff --git a/apiserver/plane/api/urls/project.py b/apiserver/plane/api/urls/project.py index ffd2af843..c73e84c89 100644 --- a/apiserver/plane/api/urls/project.py +++ b/apiserver/plane/api/urls/project.py @@ -9,7 +9,7 @@ urlpatterns = [ name="project", ), path( - "workspaces//projects//", + "workspaces//projects//", ProjectAPIEndpoint.as_view(), name="project", ), diff --git a/apiserver/plane/api/views/issue.py b/apiserver/plane/api/views/issue.py index 04efdd6ff..44f27fc16 100644 --- a/apiserver/plane/api/views/issue.py +++ b/apiserver/plane/api/views/issue.py @@ -250,7 +250,6 @@ class IssueAPIEndpoint(WebhookMixin, BaseAPIView): current_instance = json.dumps( IssueSerializer(issue).data, cls=DjangoJSONEncoder ) - issue.delete() issue_activity.delay( type="issue.activity.deleted", requested_data=json.dumps({"issue_id": str(pk)}), @@ -260,6 +259,7 @@ class IssueAPIEndpoint(WebhookMixin, BaseAPIView): current_instance=current_instance, epoch=int(timezone.now().timestamp()), ) + issue.delete() return Response(status=status.HTTP_204_NO_CONTENT) diff --git a/apiserver/plane/api/views/project.py b/apiserver/plane/api/views/project.py index 674e82acc..d7d052e5f 100644 --- a/apiserver/plane/api/views/project.py +++ b/apiserver/plane/api/views/project.py @@ -94,8 +94,8 @@ class ProjectAPIEndpoint(WebhookMixin, BaseAPIView): .distinct() ) - def get(self, request, slug, pk=None): - if pk is None: + def get(self, request, slug, project_id=None): + if project_id is None: sort_order_query = ProjectMember.objects.filter( member=request.user, project_id=OuterRef("pk"), @@ -124,7 +124,7 @@ class ProjectAPIEndpoint(WebhookMixin, BaseAPIView): ).data, ) else: - project = self.get_queryset().get(workspace__slug=slug, pk=pk) + project = self.get_queryset().get(workspace__slug=slug, pk=project_id) serializer = ProjectSerializer(project, fields=self.fields, expand=self.expand,) return Response(serializer.data, status=status.HTTP_200_OK) @@ -236,10 +236,10 @@ class ProjectAPIEndpoint(WebhookMixin, BaseAPIView): status=status.HTTP_410_GONE, ) - def patch(self, request, slug, pk=None): + def patch(self, request, slug, project_id=None): try: workspace = Workspace.objects.get(slug=slug) - project = Project.objects.get(pk=pk) + project = Project.objects.get(pk=project_id) serializer = ProjectSerializer( project, @@ -260,7 +260,7 @@ class ProjectAPIEndpoint(WebhookMixin, BaseAPIView): name="Triage", group="backlog", description="Default state for managing all Inbox Issues", - project_id=pk, + project_id=project_id, color="#ff7700", ) diff --git a/apiserver/plane/app/urls/project.py b/apiserver/plane/app/urls/project.py index b2819176c..d496ccaa1 100644 --- a/apiserver/plane/app/urls/project.py +++ b/apiserver/plane/app/urls/project.py @@ -75,7 +75,7 @@ urlpatterns = [ name="user-project-invitations", ), path( - "workspaces//projects/join/", + "workspaces//projects//join//", ProjectJoinEndpoint.as_view(), name="project-join", ), diff --git a/apiserver/plane/app/views/issue.py b/apiserver/plane/app/views/issue.py index b03c0ea4f..789f654b5 100644 --- a/apiserver/plane/app/views/issue.py +++ b/apiserver/plane/app/views/issue.py @@ -298,7 +298,6 @@ class IssueViewSet(WebhookMixin, BaseViewSet): current_instance = json.dumps( IssueSerializer(issue).data, cls=DjangoJSONEncoder ) - issue.delete() issue_activity.delay( type="issue.activity.deleted", requested_data=json.dumps({"issue_id": str(pk)}), @@ -308,6 +307,7 @@ class IssueViewSet(WebhookMixin, BaseViewSet): current_instance=current_instance, epoch=int(timezone.now().timestamp()), ) + issue.delete() return Response(status=status.HTTP_204_NO_CONTENT)