|
|
|
@ -1,8 +1,8 @@
|
|
|
|
|
from django import forms
|
|
|
|
|
from django.db.models import Q
|
|
|
|
|
|
|
|
|
|
from whoisdb.models import InetNum, Contact
|
|
|
|
|
from whoisdb.forms import MntFormMixin
|
|
|
|
|
from whoisdb.models import InetNum
|
|
|
|
|
from whoisdb.forms import MntFormMixin, WhoisObjectFormMixin
|
|
|
|
|
from whoisdb.validators import IP46CIDRValidator
|
|
|
|
|
|
|
|
|
|
from .models import Domain, Nameserver, ReverseZone
|
|
|
|
@ -11,14 +11,12 @@ import re
|
|
|
|
|
import ipaddress
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class DomainForm(MntFormMixin, forms.ModelForm):
|
|
|
|
|
class DomainForm(MntFormMixin, WhoisObjectFormMixin, forms.ModelForm):
|
|
|
|
|
class Meta:
|
|
|
|
|
model = Domain
|
|
|
|
|
fields = ['name', 'nameservers', 'mnt_by', 'admin_c']
|
|
|
|
|
|
|
|
|
|
def __init__(self, user, *args, **kwargs):
|
|
|
|
|
self._user = user
|
|
|
|
|
|
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
|
super(DomainForm, self).__init__(*args, **kwargs)
|
|
|
|
|
|
|
|
|
|
mnts = self._user.maintainer_set.all()
|
|
|
|
@ -33,9 +31,6 @@ class DomainForm(MntFormMixin, forms.ModelForm):
|
|
|
|
|
|
|
|
|
|
self.fields['nameservers'].queryset.distinct()
|
|
|
|
|
|
|
|
|
|
if 'admin_c' in self.fields:
|
|
|
|
|
self.fields['admin_c'].queryset = Contact.getMntQueryset(mnts, self.instance, "admin_c")
|
|
|
|
|
|
|
|
|
|
def clean_name(self):
|
|
|
|
|
name = self.cleaned_data['name'].lower()
|
|
|
|
|
if self._create:
|
|
|
|
@ -60,7 +55,7 @@ class DomainForm(MntFormMixin, forms.ModelForm):
|
|
|
|
|
return name
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class NameserverForm(MntFormMixin, forms.ModelForm):
|
|
|
|
|
class NameserverForm(MntFormMixin, WhoisObjectFormMixin, forms.ModelForm):
|
|
|
|
|
class Meta:
|
|
|
|
|
model = Nameserver
|
|
|
|
|
fields = ['name', 'glueIPv4', 'glueIPv6', 'mnt_by', 'admin_c']
|
|
|
|
@ -69,18 +64,12 @@ class NameserverForm(MntFormMixin, forms.ModelForm):
|
|
|
|
|
"glueIPv4": "Note: You can only set a glue record if the base domain of this nameserver belongs to you!"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
def __init__(self, user, *args, **kwargs):
|
|
|
|
|
self._user = user
|
|
|
|
|
|
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
|
super(NameserverForm, self).__init__(*args, **kwargs)
|
|
|
|
|
|
|
|
|
|
instance = getattr(self, "instance", None)
|
|
|
|
|
self._create = not (instance and instance.pk)
|
|
|
|
|
|
|
|
|
|
mnts = self._user.maintainer_set.all()
|
|
|
|
|
if 'admin_c' in self.fields:
|
|
|
|
|
self.fields['admin_c'].queryset = Contact.getMntQueryset(mnts, self.instance, "admin_c")
|
|
|
|
|
|
|
|
|
|
def clean_name(self):
|
|
|
|
|
name = self.cleaned_data['name'].lower().strip()
|
|
|
|
|
if not name.endswith("."):
|
|
|
|
@ -99,18 +88,6 @@ class NameserverForm(MntFormMixin, forms.ModelForm):
|
|
|
|
|
except Nameserver.MultipleObjectsReturned:
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
#zone = ".".join(name.split(".")[-3:])
|
|
|
|
|
#mnts = self._user.maintainer_set.all()
|
|
|
|
|
#domains = Domain.objects.filter(mnt_by__in=mnts)
|
|
|
|
|
#found = False
|
|
|
|
|
#for domain in domains:
|
|
|
|
|
# if domain.name == zone:
|
|
|
|
|
# found = True
|
|
|
|
|
# break
|
|
|
|
|
|
|
|
|
|
#if not found:
|
|
|
|
|
# raise forms.ValidationError("This nameserver is not under a domain you control.")
|
|
|
|
|
|
|
|
|
|
return name
|
|
|
|
|
|
|
|
|
|
def clean(self):
|
|
|
|
|