Skip to content

Commit

Permalink
chore: added draft cycle and module in draft issue (#5854)
Browse files Browse the repository at this point in the history
  • Loading branch information
NarayanBavisetti authored Oct 17, 2024
1 parent 6209aee commit b6a7e45
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions apiserver/plane/app/views/workspace/draft.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,9 +260,9 @@ def create_draft_to_issue(self, request, slug, draft_id):
origin=request.META.get("HTTP_ORIGIN"),
)

if draft_issue.cycle_id:
if request.data.get("cycle_id", None):
created_records = CycleIssue.objects.create(
cycle_id=draft_issue.cycle_id,
cycle_id=request.data.get("cycle_id", None),
issue_id=serializer.data.get("id", None),
project_id=draft_issue.project_id,
workspace_id=draft_issue.workspace_id,
Expand All @@ -289,7 +289,7 @@ def create_draft_to_issue(self, request, slug, draft_id):
origin=request.META.get("HTTP_ORIGIN"),
)

if draft_issue.module_ids:
if request.data.get("module_ids", []):
# bulk create the module
ModuleIssue.objects.bulk_create(
[
Expand All @@ -301,11 +301,11 @@ def create_draft_to_issue(self, request, slug, draft_id):
created_by_id=draft_issue.created_by_id,
updated_by_id=draft_issue.updated_by_id,
)
for module in draft_issue.module_ids
for module in request.data.get("module_ids", [])
],
batch_size=10,
)
# Bulk Update the activity
# Update the activity
_ = [
issue_activity.delay(
type="module.activity.created",
Expand All @@ -318,7 +318,7 @@ def create_draft_to_issue(self, request, slug, draft_id):
notification=True,
origin=request.META.get("HTTP_ORIGIN"),
)
for module in draft_issue.module_ids
for module in request.data.get("module_ids", [])
]

# Update file assets
Expand All @@ -332,12 +332,6 @@ def create_draft_to_issue(self, request, slug, draft_id):
# delete the draft issue
draft_issue.delete()

# delete the draft issue module
DraftIssueModule.objects.filter(draft_issue=draft_issue).delete()

# delete the draft issue cycle
DraftIssueCycle.objects.filter(draft_issue=draft_issue).delete()

return Response(serializer.data, status=status.HTTP_201_CREATED)

return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)

0 comments on commit b6a7e45

Please sign in to comment.