Simplify ttl and key_name form fields. keys are now required.

fix forms where the widget was being specified but overriden in the view. remove the specification of the widget
This commit is contained in:
Jeffrey Forman 2017-04-17 20:18:14 -04:00
parent 07b0df4b7d
commit 235f0fe174
1 changed files with 8 additions and 25 deletions

View File

@ -54,18 +54,12 @@ class FormAddForwardRecord(forms.Form):
record_name = forms.RegexField(max_length=100, record_name = forms.RegexField(max_length=100,
regex="^[a-zA-Z0-9-_]+$", regex="^[a-zA-Z0-9-_]+$",
required=False) required=False)
record_type = forms.ChoiceField(choices=settings.RECORD_TYPE_CHOICES, record_type = forms.ChoiceField(choices=settings.RECORD_TYPE_CHOICES)
widget=forms.RadioSelect)
zone_name = forms.CharField(max_length=100) zone_name = forms.CharField(max_length=100)
record_data = forms.CharField(max_length=100) record_data = forms.CharField(max_length=100)
ttl = forms.ChoiceField(choices=settings.TTL_CHOICES, ttl = forms.ChoiceField(choices=settings.TTL_CHOICES)
widget=forms.RadioSelect)
create_reverse = forms.BooleanField(required=False) create_reverse = forms.BooleanField(required=False)
key_name = forms.ModelChoiceField(queryset=Key.objects.all(), key_name = forms.ModelChoiceField(queryset=Key.objects.all(), required=True)
required=False,
widget=forms.RadioSelect,
empty_label=None)
def clean(self): def clean(self):
cleaned_data = super(FormAddForwardRecord, self).clean() cleaned_data = super(FormAddForwardRecord, self).clean()
@ -89,13 +83,9 @@ class FormAddReverseRecord(forms.Form):
"is PTR."}) "is PTR."})
zone_name = forms.CharField(max_length=100) zone_name = forms.CharField(max_length=100)
record_data = CustomStringPeriodSuffix(required=True) record_data = CustomStringPeriodSuffix(required=True)
ttl = forms.ChoiceField(choices=settings.TTL_CHOICES, ttl = forms.ChoiceField(choices=settings.TTL_CHOICES)
widget=forms.RadioSelect)
key_name = forms.ModelChoiceField(queryset=Key.objects.all(),
required=False,
widget=forms.RadioSelect,
empty_label=None)
create_reverse = forms.BooleanField(required=False) create_reverse = forms.BooleanField(required=False)
key_name = forms.ModelChoiceField(queryset=Key.objects.all(), required=True)
class FormAddCnameRecord(forms.Form): class FormAddCnameRecord(forms.Form):
@ -106,12 +96,8 @@ class FormAddCnameRecord(forms.Form):
originating_record = forms.CharField(max_length=100) originating_record = forms.CharField(max_length=100)
cname = forms.RegexField(max_length=100, regex="^[a-zA-Z0-9-_]+$") cname = forms.RegexField(max_length=100, regex="^[a-zA-Z0-9-_]+$")
zone_name = forms.CharField(max_length=256) zone_name = forms.CharField(max_length=256)
ttl = forms.ChoiceField(choices=settings.TTL_CHOICES, ttl = forms.ChoiceField(choices=settings.TTL_CHOICES)
widget=forms.RadioSelect) key_name = forms.ModelChoiceField(queryset=Key.objects.all(), required=True)
key_name = forms.ModelChoiceField(queryset=Key.objects.all(),
required=False,
widget=forms.RadioSelect,
empty_label=None)
class FormDeleteRecord(forms.Form): class FormDeleteRecord(forms.Form):
@ -121,7 +107,4 @@ class FormDeleteRecord(forms.Form):
dns_server = forms.CharField(max_length=100) dns_server = forms.CharField(max_length=100)
zone_name = forms.CharField(max_length=256) zone_name = forms.CharField(max_length=256)
rr_list = CustomUnicodeListField() rr_list = CustomUnicodeListField()
key_name = forms.ModelChoiceField(queryset=Key.objects.all(), key_name = forms.ModelChoiceField(queryset=Key.objects.all(), required=True)
required=False,
widget=forms.RadioSelect,
empty_label=None)