add choice selection to record type when adding record. works for A/AAAA records.

This commit is contained in:
Jeffrey Forman 2012-12-02 09:13:22 -05:00
parent e477a23ba4
commit aa76d59a13
4 changed files with 8 additions and 5 deletions

View File

@ -27,7 +27,7 @@ class FormAddRecord(forms.Form):
""" Form used to add a DNS record. """ """ Form used to add a DNS record. """
dns_server = forms.CharField(max_length=100) dns_server = forms.CharField(max_length=100)
record_name = forms.RegexField(max_length=100, regex="^[a-zA-Z0-9-_]+$", required=False) record_name = forms.RegexField(max_length=100, regex="^[a-zA-Z0-9-_]+$", required=False)
record_type = forms.CharField(max_length=10) record_type = forms.ChoiceField(choices=local_settings.RECORD_TYPE_CHOICES)
zone_name = forms.CharField(max_length=100) zone_name = forms.CharField(max_length=100)
record_data = forms.GenericIPAddressField() record_data = forms.GenericIPAddressField()
ttl = forms.ChoiceField(choices=local_settings.TTL_CHOICES) ttl = forms.ChoiceField(choices=local_settings.TTL_CHOICES)

View File

@ -7,5 +7,4 @@ TTL_CHOICES = ((300, "5 minutes"),
(86400, "1 day")) (86400, "1 day"))
RECORD_TYPE_CHOICES = (("A", "A"), RECORD_TYPE_CHOICES = (("A", "A"),
("AAAA", "AAAA"), ("AAAA", "AAAA"))
("CNAME", "CNAME"))

View File

@ -36,8 +36,11 @@ Add record in {{ zone_name }}
<label class="control-label">Record Type: </label> <label class="control-label">Record Type: </label>
<div class="controls"> <div class="controls">
<select name="record_type"> <select name="record_type">
<option value="A" selected="selected">A</option> {% for type, name in record_type_choices %}
<option value="AAAA">AAAA</option> <option value="{{name}}">
{{name}}
</option>
{% endfor %}
</select> </select>
</div> </div>
</div> </div>

View File

@ -66,6 +66,7 @@ def view_add_record(request, dns_server, zone_name):
"zone_name" : zone_name, "zone_name" : zone_name,
"tsig_keys" : models.Key.objects.all(), "tsig_keys" : models.Key.objects.all(),
"ttl_choices" : local_settings.TTL_CHOICES, "ttl_choices" : local_settings.TTL_CHOICES,
"record_type_choices" : local_settings.RECORD_TYPE_CHOICES,
}) })
def view_add_record_result(request): def view_add_record_result(request):