File tree Expand file tree Collapse file tree 1 file changed +14
-12
lines changed
Expand file tree Collapse file tree 1 file changed +14
-12
lines changed Original file line number Diff line number Diff line change @@ -353,18 +353,20 @@ def update_submission(
353353 )
354354 )
355355
356- ProposalMaterial .objects .filter (
357- proposal = instance ,
358- id__in = [
359- m .id
360- for m in existing_materials .values ()
361- if m not in materials_to_update
362- ],
363- ).delete ()
364- ProposalMaterial .objects .bulk_create (materials_to_create )
365- ProposalMaterial .objects .bulk_update (
366- materials_to_update , fields = ["name" , "url" , "file_id" ]
367- )
356+ if to_delete := [
357+ m .id for m in existing_materials .values () if m not in materials_to_update
358+ ]:
359+ ProposalMaterial .objects .filter (
360+ proposal = instance ,
361+ id__in = to_delete ,
362+ ).delete ()
363+
364+ if materials_to_create :
365+ ProposalMaterial .objects .bulk_create (materials_to_create )
366+ if materials_to_update :
367+ ProposalMaterial .objects .bulk_update (
368+ materials_to_update , fields = ["name" , "url" , "file_id" ]
369+ )
368370
369371 Participant .objects .update_or_create (
370372 user_id = request .user .id ,
You can’t perform that action at this time.
0 commit comments