fix: module update serializer and removed create

This commit is contained in:
pablohashescobar 2022-12-22 17:00:20 +05:30
parent 9046bff659
commit 364ad0a301

View File

@ -52,6 +52,7 @@ class ModuleWriteSerializer(BaseSerializer):
for member in members for member in members
], ],
batch_size=10, batch_size=10,
ignore_conflicts=True,
) )
return module return module
@ -59,24 +60,22 @@ class ModuleWriteSerializer(BaseSerializer):
def update(self, instance, validated_data): def update(self, instance, validated_data):
members = validated_data.pop("members_list", None) members = validated_data.pop("members_list", None)
module = Module.objects.create(**validated_data, project=instance.project)
if members is not None: if members is not None:
ModuleIssue.objects.filter(module=instance).delete()
ModuleMember.objects.bulk_create( ModuleMember.objects.bulk_create(
[ [
ModuleMember( ModuleMember(
module=module, module=instance,
member=member, member=member,
project=instance.project, project=instance.project,
workspace=instance.project.workspace, workspace=instance.project.workspace,
created_by=module.created_by, created_by=instance.created_by,
updated_by=module.updated_by, updated_by=instance.updated_by,
) )
for member in members for member in members
], ],
batch_size=10, batch_size=10,
ignore_conflicts=True
) )
return super().update(instance, validated_data) return super().update(instance, validated_data)