diff --git a/binder/forms.py b/binder/forms.py index 133e46c..ffa18b6 100644 --- a/binder/forms.py +++ b/binder/forms.py @@ -6,14 +6,7 @@ from django.core.exceptions import ValidationError # App Imports from models import Key - -TTL_CHOICES = ((300, "5 minutes"), - (1800, "30 minutes"), - (3600, "1 hour"), - (43200, "12 hours"), - (86400, "1 day")) - -RECORD_TYPE_CHOICES = (("A", "A"), ("AAAA", "AAAA"), ("CNAME", "CNAME")) +import local_settings ### Custom Form Fields @@ -37,7 +30,7 @@ class FormAddRecord(forms.Form): record_type = forms.CharField(max_length=10) zone_name = forms.CharField(max_length=100) record_data = forms.GenericIPAddressField() - ttl = forms.IntegerField(min_value=1) + ttl = forms.ChoiceField(choices=local_settings.TTL_CHOICES) create_reverse = forms.BooleanField(required=False) key_name = forms.ModelChoiceField(queryset=Key.objects.all(), required=False) @@ -48,7 +41,7 @@ class FormAddCnameRecord(forms.Form): originating_record = forms.CharField(max_length=100) cname = forms.RegexField(max_length=100, regex="^[a-zA-Z0-9-_]+$") zone_name = forms.CharField(max_length=256) - ttl = forms.ChoiceField(choices=TTL_CHOICES) + ttl = forms.ChoiceField(choices=local_settings.TTL_CHOICES) key_name = forms.ModelChoiceField(queryset=Key.objects.all(), required=False) class FormDeleteRecord(forms.Form): diff --git a/binder/local_settings.py b/binder/local_settings.py new file mode 100644 index 0000000..4b48764 --- /dev/null +++ b/binder/local_settings.py @@ -0,0 +1,11 @@ +### Local settings to be shared across modules. + +TTL_CHOICES = ((300, "5 minutes"), + (1800, "30 minutes"), + (3600, "1 hour"), + (43200, "12 hours"), + (86400, "1 day")) + +RECORD_TYPE_CHOICES = (("A", "A"), + ("AAAA", "AAAA"), + ("CNAME", "CNAME")) diff --git a/binder/templates/bcommon/add_cname_record_form.htm b/binder/templates/bcommon/add_cname_record_form.htm index 6e973e0..db75ed0 100644 --- a/binder/templates/bcommon/add_cname_record_form.htm +++ b/binder/templates/bcommon/add_cname_record_form.htm @@ -42,7 +42,11 @@ Add CNAME record for {{ originating_record }}
diff --git a/binder/templates/bcommon/add_record_form.htm b/binder/templates/bcommon/add_record_form.htm index 1aac8cc..5f19d71 100644 --- a/binder/templates/bcommon/add_record_form.htm +++ b/binder/templates/bcommon/add_record_form.htm @@ -60,7 +60,11 @@ Add record in {{ zone_name }}
diff --git a/binder/views.py b/binder/views.py index 67df271..684bee8 100644 --- a/binder/views.py +++ b/binder/views.py @@ -5,6 +5,7 @@ from django.shortcuts import redirect, render # App Imports from binder import exceptions, forms, helpers, models +import local_settings def home_index(request): """ List the main index page for Binder. """ @@ -63,7 +64,9 @@ def view_add_record(request, dns_server, zone_name): return render(request, "bcommon/add_record_form.htm", { "dns_server" : dns_server, "zone_name" : zone_name, - "tsig_keys" : models.Key.objects.all() }) + "tsig_keys" : models.Key.objects.all(), + "ttl_choices" : local_settings.TTL_CHOICES, + }) def view_add_record_result(request): """ Process the input given to add a DNS record. """ @@ -104,6 +107,7 @@ def view_add_cname_record(request, dns_server, zone_name, record_name): { "dns_server" : dns_server, "originating_record" : "%s.%s" % (record_name, zone_name), "zone_name" : zone_name, + "ttl_choices" : local_settings.TTL_CHOICES, "tsig_keys" : models.Key.objects.all() }) def view_add_cname_result(request):