Nameserver mnts, glue magic
This commit is contained in:
parent
697f203974
commit
123503b8dd
|
@ -95,9 +95,15 @@ class NameserverForm(MntFormMixin, WhoisObjectFormMixin, forms.ModelForm):
|
|||
|
||||
if not self.errors:
|
||||
name = cleaned_data.get("name")
|
||||
mntBy = cleaned_data.get("mnt_by")
|
||||
zone = ".".join(name.split(".")[-3:])
|
||||
ipv4 = cleaned_data.get("glueIPv4")
|
||||
ipv6 = cleaned_data.get("glueIPv6")
|
||||
ipv4 = cleaned_data.get("glueIPv4", None)
|
||||
ipv6 = cleaned_data.get("glueIPv6", None)
|
||||
|
||||
if not ipv4:
|
||||
ipv4 = None
|
||||
if not ipv6:
|
||||
ipv6 = None
|
||||
|
||||
if self._create and (ipv4 or ipv6) or not self._create and not (self.instance.glueIPv4 == ipv4 and self.instance.glueIPv6 == ipv6):
|
||||
mnts = self._user.maintainer_set.all()
|
||||
|
@ -111,6 +117,17 @@ 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.")
|
||||
|
||||
failedMnts = set()
|
||||
for ns in Nameserver.objects.filter(name=name, mnt_by__in=mntBy):
|
||||
if self._create or self.instance.pk != ns.pk:
|
||||
for mnt in ns.mnt_by.all():
|
||||
if mnt in mntBy:
|
||||
failedMnts.add(mnt.handle)
|
||||
|
||||
if len(failedMnts) > 0:
|
||||
raise forms.ValidationError("The following maintainer objects already have this nameservers: %s" % ", ".join(failedMnts))
|
||||
|
||||
|
||||
return cleaned_data
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue