From 2cf1f32353bad90a1319bc3ac18a917d098d2482 Mon Sep 17 00:00:00 2001 From: pablohashescobar Date: Tue, 20 Dec 2022 16:03:50 +0530 Subject: [PATCH] refactor: make both cycle issue and module issue view consistent --- apiserver/plane/api/views/cycle.py | 2 +- apiserver/plane/api/views/module.py | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/apiserver/plane/api/views/cycle.py b/apiserver/plane/api/views/cycle.py index 873f9518c..e79d240ed 100644 --- a/apiserver/plane/api/views/cycle.py +++ b/apiserver/plane/api/views/cycle.py @@ -70,7 +70,7 @@ class CycleIssueViewSet(BaseViewSet): def create(self, request, slug, project_id, cycle_id): try: - issues = request.data.get("issue", []) + issues = request.data.get("issues", []) if not len(issues): return Response( diff --git a/apiserver/plane/api/views/module.py b/apiserver/plane/api/views/module.py index a8e4136b6..888b5b8d6 100644 --- a/apiserver/plane/api/views/module.py +++ b/apiserver/plane/api/views/module.py @@ -15,7 +15,7 @@ from plane.api.serializers import ( ModuleIssueSerializer, ) from plane.api.permissions import ProjectEntityPermission -from plane.db.models import Module, ModuleIssue, Project +from plane.db.models import Module, ModuleIssue, Project, Issue class ModuleViewSet(BaseViewSet): @@ -78,7 +78,6 @@ class ModuleViewSet(BaseViewSet): {"error": "Something went wrong please try again later"}, status=status.HTTP_500_INTERNAL_SERVER_ERROR, ) - class ModuleIssueViewSet(BaseViewSet): @@ -126,6 +125,11 @@ class ModuleIssueViewSet(BaseViewSet): module = Module.objects.get( workspace__slug=slug, project_id=project_id, pk=module_id ) + + issues = Issue.objects.filter( + pk__in=issues, workspace__slug=slug, project_id=project_id + ) + ModuleIssue.objects.bulk_create( [ ModuleIssue(