diff --git a/domains/forms.py b/domains/forms.py index dd3cc9d..87c3731 100644 --- a/domains/forms.py +++ b/domains/forms.py @@ -121,6 +121,16 @@ class NameserverForm(MntFormMixin, WhoisObjectFormMixin, forms.ModelForm): if not found: raise forms.ValidationError("You have glue IPs set, but this domain is not under a domain you control.") + if ipv4 or ipv6: + try: + ns = Nameserver.objects.get(Q(name=name) & (Q(glueIPv4__isnull=False) | Q(glueIPv6__isnull=False))) + if self._create or ns.pk != self.instance.pk: + nsMnts = ", ".join(n.handle for n in ns.mnt_by.all()) + + raise forms.ValidationError("Only one nameserver for this domain can have glue records and one already exists (maintained by %s)" % nsMnts) + except Nameserver.DoesNotExist: + pass + failedMnts = set() for ns in Nameserver.objects.filter(name=name, mnt_by__in=mntBy): if self._create or self.instance.pk != ns.pk: