@@ -260,9 +260,9 @@ def create_draft_to_issue(self, request, slug, draft_id):
260260 origin = request .META .get ("HTTP_ORIGIN" ),
261261 )
262262
263- if draft_issue . cycle_id :
263+ if request . data . get ( " cycle_id" , None ) :
264264 created_records = CycleIssue .objects .create (
265- cycle_id = draft_issue . cycle_id ,
265+ cycle_id = request . data . get ( " cycle_id" , None ) ,
266266 issue_id = serializer .data .get ("id" , None ),
267267 project_id = draft_issue .project_id ,
268268 workspace_id = draft_issue .workspace_id ,
@@ -289,7 +289,7 @@ def create_draft_to_issue(self, request, slug, draft_id):
289289 origin = request .META .get ("HTTP_ORIGIN" ),
290290 )
291291
292- if draft_issue . module_ids :
292+ if request . data . get ( " module_ids" , []) :
293293 # bulk create the module
294294 ModuleIssue .objects .bulk_create (
295295 [
@@ -301,11 +301,11 @@ def create_draft_to_issue(self, request, slug, draft_id):
301301 created_by_id = draft_issue .created_by_id ,
302302 updated_by_id = draft_issue .updated_by_id ,
303303 )
304- for module in draft_issue . module_ids
304+ for module in request . data . get ( " module_ids" , [])
305305 ],
306306 batch_size = 10 ,
307307 )
308- # Bulk Update the activity
308+ # Update the activity
309309 _ = [
310310 issue_activity .delay (
311311 type = "module.activity.created" ,
@@ -318,7 +318,7 @@ def create_draft_to_issue(self, request, slug, draft_id):
318318 notification = True ,
319319 origin = request .META .get ("HTTP_ORIGIN" ),
320320 )
321- for module in draft_issue . module_ids
321+ for module in request . data . get ( " module_ids" , [])
322322 ]
323323
324324 # Update file assets
@@ -332,12 +332,6 @@ def create_draft_to_issue(self, request, slug, draft_id):
332332 # delete the draft issue
333333 draft_issue .delete ()
334334
335- # delete the draft issue module
336- DraftIssueModule .objects .filter (draft_issue = draft_issue ).delete ()
337-
338- # delete the draft issue cycle
339- DraftIssueCycle .objects .filter (draft_issue = draft_issue ).delete ()
340-
341335 return Response (serializer .data , status = status .HTTP_201_CREATED )
342336
343337 return Response (serializer .errors , status = status .HTTP_400_BAD_REQUEST )
0 commit comments