perf: automation task name validate (#9690)

Co-authored-by: feng <1304903146@qq.com>
pull/9691/head
fit2bot 2 years ago committed by GitHub
parent ee3c548b6b
commit 7ceb27301b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -38,7 +38,7 @@ class BaseAutomationSerializer(PeriodTaskSerializerMixin, BulkOrgResourceModelSe
} }
def validate_name(self, name): def validate_name(self, name):
if self.instance: if self.instance and self.instance.name == name:
return name return name
if BaseAutomation.objects.filter(name=name, type=self.model_type).exists(): if BaseAutomation.objects.filter(name=name, type=self.model_type).exists():
raise serializers.ValidationError(_('Name already exists')) raise serializers.ValidationError(_('Name already exists'))

Loading…
Cancel
Save