Merge branch 'revised-local-settings' of https://github.com/Dunedan/binder into Dunedan-revised-local-settings

fixed import of get_object_or_404 which was erroneously removed

Conflicts:
	binder/views.py
This commit is contained in:
jeffrey forman 2015-05-27 20:14:50 -04:00
commit d625e0245b
5 changed files with 27 additions and 22 deletions

1
.gitignore vendored
View File

@ -5,3 +5,4 @@
*.conf *.conf
*~ *~
/binder/secret.txt /binder/secret.txt
/binder/local_settings.py

View File

@ -2,11 +2,11 @@
# 3rd Party # 3rd Party
from django import forms from django import forms
from django.conf import settings
from django.forms import ValidationError from django.forms import ValidationError
# App Imports # App Imports
from models import Key from models import Key
import local_settings
### Custom Form Fields ### Custom Form Fields
@ -40,10 +40,10 @@ class FormAddForwardRecord(forms.Form):
""" Form used to add a Forward DNS record. """ """ Form used to add a Forward 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.ChoiceField(choices=local_settings.RECORD_TYPE_CHOICES) record_type = forms.ChoiceField(choices=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=settings.TTL_CHOICES)
create_reverse = forms.BooleanField(required=False) create_reverse = forms.BooleanField(required=False)
key_name = forms.ModelChoiceField(queryset=Key.objects.all(), required=False) key_name = forms.ModelChoiceField(queryset=Key.objects.all(), required=False)
@ -54,7 +54,7 @@ class FormAddReverseRecord(forms.Form):
record_type = forms.RegexField(regex=r"^PTR$",error_messages={"invalid" : "The only valid choice here is PTR."}) record_type = forms.RegexField(regex=r"^PTR$",error_messages={"invalid" : "The only valid choice here 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=local_settings.TTL_CHOICES) ttl = forms.ChoiceField(choices=settings.TTL_CHOICES)
key_name = forms.ModelChoiceField(queryset=Key.objects.all(), required=False) key_name = forms.ModelChoiceField(queryset=Key.objects.all(), required=False)
create_reverse = forms.BooleanField(required=False) create_reverse = forms.BooleanField(required=False)
@ -64,7 +64,7 @@ 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=local_settings.TTL_CHOICES) ttl = forms.ChoiceField(choices=settings.TTL_CHOICES)
key_name = forms.ModelChoiceField(queryset=Key.objects.all(), required=False) key_name = forms.ModelChoiceField(queryset=Key.objects.all(), required=False)
class FormDeleteRecord(forms.Form): class FormDeleteRecord(forms.Form):

View File

@ -1,10 +0,0 @@
### 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"))

View File

@ -86,3 +86,17 @@ INSTALLED_APPS = (
) )
TEST_RUNNER = 'django.test.runner.DiscoverRunner' TEST_RUNNER = 'django.test.runner.DiscoverRunner'
TTL_CHOICES = ((300, "5 minutes"),
(1800, "30 minutes"),
(3600, "1 hour"),
(43200, "12 hours"),
(86400, "1 day"))
RECORD_TYPE_CHOICES = (("A", "A"),
("AAAA", "AAAA"))
try:
from local_settings import *
except ImportError:
pass

View File

@ -1,11 +1,11 @@
### Binder VIews ### Binder VIews
# 3rd Party # 3rd Party
from django.conf import settings
from django.shortcuts import get_object_or_404, redirect, render from django.shortcuts import get_object_or_404, redirect, render
# App Imports # App Imports
from binder import exceptions, forms, helpers, models from binder import exceptions, forms, helpers, models
import local_settings
def home_index(request): def home_index(request):
""" List the main index page for Binder. """ """ List the main index page for Binder. """
@ -71,8 +71,8 @@ def view_add_record(request, dns_server, zone_name):
{ "dns_server" : this_server, { "dns_server" : this_server,
"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": settings.TTL_CHOICES,
"record_type_choices" : local_settings.RECORD_TYPE_CHOICES, "record_type_choices": settings.RECORD_TYPE_CHOICES,
}) })
@ -117,8 +117,8 @@ def view_add_record_result(request):
{ "dns_server" : dns_server, { "dns_server" : dns_server,
"zone_name" : request.POST["zone_name"], "zone_name" : request.POST["zone_name"],
"tsig_keys" : models.Key.objects.all(), "tsig_keys" : models.Key.objects.all(),
"ttl_choices" : local_settings.TTL_CHOICES, "ttl_choices": settings.TTL_CHOICES,
"record_type_choices" : local_settings.RECORD_TYPE_CHOICES, "record_type_choices": settings.RECORD_TYPE_CHOICES,
"form_errors" : form.errors, "form_errors" : form.errors,
"form_data" : request.POST }) "form_data" : request.POST })
@ -132,7 +132,7 @@ def view_add_cname_record(request, dns_server, zone_name, record_name):
{ "dns_server" : this_server, { "dns_server" : this_server,
"originating_record" : "%s.%s" % (record_name, zone_name), "originating_record" : "%s.%s" % (record_name, zone_name),
"zone_name" : zone_name, "zone_name" : zone_name,
"ttl_choices" : local_settings.TTL_CHOICES, "ttl_choices": settings.TTL_CHOICES,
"tsig_keys" : models.Key.objects.all() }) "tsig_keys" : models.Key.objects.all() })
@ -170,7 +170,7 @@ def view_add_cname_result(request):
"originating_record" : request.POST["originating_record"], "originating_record" : request.POST["originating_record"],
"form_data" : request.POST, "form_data" : request.POST,
"form_errors" : form.errors, "form_errors" : form.errors,
"ttl_choices" : local_settings.TTL_CHOICES, "ttl_choices": settings.TTL_CHOICES,
"tsig_keys" : models.Key.objects.all() }) "tsig_keys" : models.Key.objects.all() })